[regalloc] Run SpillPlacer on any value defined in a loop

I previously wrote a comment that said "We haven't seen any indication
of performance improvements from seeking optimal spilling positions
except on loop-top phi values". That statement is no longer true, now
that I've looked a little harder. In the latest version of the Mono
interpreter, we can improve performance by 2.5% by enabling SpillPlacer
for any value defined within a loop.

Bug: v8:10606
Change-Id: I25e06458c87ad4ffcefe52be3042032e05a47b35
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2381557
Reviewed-by: Thibaud Michaud <thibaudm@chromium.org>
Reviewed-by: Ross McIlroy <rmcilroy@chromium.org>
Commit-Queue: Seth Brenith <seth.brenith@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#69646}
This commit is contained in:
Seth Brenith 2020-08-28 07:25:47 -07:00 committed by Commit Bot
parent 42fcb2c25f
commit 7f05467914
3 changed files with 6 additions and 5 deletions

View File

@ -1430,6 +1430,7 @@ class V8_EXPORT_PRIVATE InstructionBlock final
return loop_end_;
}
inline bool IsLoopHeader() const { return loop_end_.IsValid(); }
bool IsInLoop() const { return IsLoopHeader() || loop_header().IsValid(); }
inline bool IsSwitchTarget() const { return switch_target_; }
inline bool ShouldAlign() const { return alignment_; }

View File

@ -40,12 +40,12 @@ void SpillPlacer::Add(TopLevelLiveRange* range) {
// the earliest deferred block as the insertion point would cause
// incorrect behavior, so the value must be spilled at the definition.
// - We haven't seen any indication of performance improvements from seeking
// optimal spilling positions except on loop-top phi values, so spill
// any value that isn't a loop-top phi at the definition to avoid
// increasing the code size for no benefit.
// optimal spilling positions for values defined outside loops, so spill
// those values at the definition to avoid increasing the code size for no
// benefit.
if (range->GetSpillMoveInsertionLocations(data()) == nullptr ||
range->spilled() || top_start_block->IsDeferred() ||
(!FLAG_stress_turbo_late_spilling && !range->is_loop_phi())) {
(!FLAG_stress_turbo_late_spilling && !top_start_block->IsInLoop())) {
range->CommitSpillMoves(data(), spill_operand);
return;
}

View File

@ -562,7 +562,7 @@ DEFINE_BOOL(turbo_control_flow_aware_allocation, true,
"consider control flow while allocating registers")
DEFINE_BOOL(
stress_turbo_late_spilling, false,
"optimize placement of all spill instructions, not just loop-top phis")
"optimize placement of all spill instructions, not just loop values")
DEFINE_STRING(turbo_filter, "*", "optimization filter for TurboFan compiler")
DEFINE_BOOL(trace_turbo, false, "trace generated TurboFan IR")