Commit 970d9076 authored by mtrofin's avatar mtrofin Committed by Commit bot

[turbofan] Regalloc was assuming "blocked" register can't be "used"

When attempting to allocate a blocked register, in the absence of
aliasing, it was possible to assume that a register that was
blocked - by either belonging to an active fixed register, or to
an active unspillable range - could not have possibly be allocated
to another active range (because there'd be an interference otherwise).

With aliasing, that changes. The range we're trying to allocate
may be a double, while the 2 or more active ranges in the paragraph
above may be singles aliasing to the same double slot.

Opportunistically refactored for readability an optimization, and
added some comments.

BUG=681529

Review-Url: https://codereview.chromium.org/2632373004
Cr-Commit-Position: refs/heads/master@{#42474}
parent aa3cd2cd
......@@ -3175,6 +3175,9 @@ void LinearScanAllocator::AllocateBlockedReg(LiveRange* current) {
rep == MachineRepresentation::kSimd128))
GetFPRegisterSet(rep, &num_regs, &num_codes, &codes);
// use_pos keeps track of positions a register/alias is used at.
// block_pos keeps track of positions where a register/alias is blocked
// from.
LifetimePosition use_pos[RegisterConfiguration::kMaxFPRegisters];
LifetimePosition block_pos[RegisterConfiguration::kMaxFPRegisters];
for (int i = 0; i < num_regs; i++) {
......@@ -3190,6 +3193,8 @@ void LinearScanAllocator::AllocateBlockedReg(LiveRange* current) {
block_pos[cur_reg] = use_pos[cur_reg] =
LifetimePosition::GapFromInstructionIndex(0);
} else {
DCHECK_NE(LifetimePosition::GapFromInstructionIndex(0),
block_pos[cur_reg]);
use_pos[cur_reg] =
range->NextLifetimePositionRegisterIsBeneficial(current->Start());
}
......@@ -3205,7 +3210,9 @@ void LinearScanAllocator::AllocateBlockedReg(LiveRange* current) {
LifetimePosition::GapFromInstructionIndex(0);
} else {
use_pos[aliased_reg] =
range->NextLifetimePositionRegisterIsBeneficial(current->Start());
Min(block_pos[aliased_reg],
range->NextLifetimePositionRegisterIsBeneficial(
current->Start()));
}
}
}
......@@ -3219,10 +3226,12 @@ void LinearScanAllocator::AllocateBlockedReg(LiveRange* current) {
// Don't perform costly intersections if they are guaranteed to not update
// block_pos or use_pos.
// TODO(mtrofin): extend to aliased ranges, too.
if ((kSimpleFPAliasing || !check_fp_aliasing()) && is_fixed) {
if (block_pos[cur_reg] < range->Start()) continue;
} else {
if (use_pos[cur_reg] < range->Start()) continue;
if ((kSimpleFPAliasing || !check_fp_aliasing())) {
if (is_fixed) {
if (block_pos[cur_reg] < range->Start()) continue;
} else {
if (use_pos[cur_reg] < range->Start()) continue;
}
}
LifetimePosition next_intersection = range->FirstIntersection(current);
......
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