Commit 9c378dad authored by Thibaud Michaud's avatar Thibaud Michaud Committed by Commit Bot

[regalloc] Reuse existing method to find intersection

The current code for AssignRegisterOnReload starts the search at
the first interval instead of relying on the cached {current_interval_},
which seems to be a main cause for slow compile time in the linked
issue's test case. Moreover, it does not take into account live range
holes of the current range. This change uses FirstIntersection instead
which already handles both issues.
Since inactive ranges are sorted by their next start, we can also break
early from the loop.

R=sigurds@chromium.org

Bug: v8:10533
Change-Id: I454df95376011462ce22e850a1c143d523b68538
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2263152
Commit-Queue: Thibaud Michaud <thibaudm@chromium.org>
Reviewed-by: 's avatarSigurd Schneider <sigurds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68551}
parent 91bf68ae
......@@ -3320,18 +3320,20 @@ LiveRange* LinearScanAllocator::AssignRegisterOnReload(LiveRange* range,
if ((kSimpleFPAliasing || !check_fp_aliasing()) && cur_reg != reg) {
continue;
}
for (const auto cur_inactive : inactive_live_ranges(cur_reg)) {
for (const LiveRange* cur_inactive : inactive_live_ranges(cur_reg)) {
if (!kSimpleFPAliasing && check_fp_aliasing() &&
!data()->config()->AreAliases(cur_inactive->representation(), cur_reg,
range->representation(), reg)) {
continue;
}
for (auto interval = cur_inactive->first_interval(); interval != nullptr;
interval = interval->next()) {
if (interval->start() > new_end) break;
if (interval->end() <= range->Start()) continue;
if (new_end > interval->start()) new_end = interval->start();
if (new_end <= cur_inactive->NextStart()) {
// Inactive ranges are sorted by their next start, so the remaining
// ranges cannot contribute to new_end.
break;
}
auto next_intersection = cur_inactive->FirstIntersection(range);
if (!next_intersection.IsValid()) continue;
new_end = std::min(new_end, next_intersection);
}
}
if (new_end != range->End()) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment