Skip to content

Commit 51d2067

Browse files
thibaudmichaudV8 LUCI CQ
authored andcommitted
[regalloc] Enable spill placer for non loop-top phis
The spill placer is only enabled for loop-top phis because we did not see benefits for other kinds of live ranges at the time. Other ranges are guarded by "--stress-turbo-late-spilling". However, we just observed that the JetStream dotnet-interp-wasm benchmark contains an expensive register spill at the start of each interpreter loop iteration for a non-phi range, and greatly benefits from moving the spill down into the (rare) successor blocks that actually require the value to be on the stack. Enable the flag by default and rename it to "--turbo-always-optimize-spills". This is expected to slightly increase code size in some cases, but this should never increase the number of spills on any control-flow path. [email protected] Bug: 475502210 Change-Id: I91b31c632da7ec192d3a41a61a79d561b13fcf18 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/7510687 Reviewed-by: Daniel Lehmann <[email protected]> Commit-Queue: Thibaud Michaud <[email protected]> Cr-Commit-Position: refs/heads/main@{#104853}
1 parent ea50d3f commit 51d2067

3 files changed

Lines changed: 7 additions & 7 deletions

File tree

BUILD.gn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2707,7 +2707,7 @@ template("run_mksnapshot") {
27072707
"root_out_dir") + "/mksnapshot",
27082708
root_build_dir),
27092709
"--turbo_instruction_scheduling",
2710-
"--stress-turbo-late-spilling",
2710+
"--turbo-always-optimize-spills",
27112711

27122712
# In cross builds, the snapshot may be generated for both the host and
27132713
# target toolchains. The same host binary is used to generate both, so

src/compiler/backend/spill-placer.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ void SpillPlacer::Add(TopLevelLiveRange* range) {
3838
// - If the value is defined in a deferred block, then the logic to select
3939
// the earliest deferred block as the insertion point would cause
4040
// incorrect behavior, so the value must be spilled at the definition.
41-
// - We haven't seen any indication of performance improvements from seeking
42-
// optimal spilling positions except on loop-top phi values, so spill
43-
// any value that isn't a loop-top phi at the definition to avoid
44-
// increasing the code size for no benefit.
41+
// - Late spilling was only enabled for loop phis initially. However, we also
42+
// saw benefits in some wasm benchmarks when enabling it for other ranges, so
43+
// the "--turbo-always-optimize-spills" flag is enabled by default now. It can
44+
// be cleaned up if this is stable and does not cause regressions.
4545
if (range->GetSpillMoveInsertionLocations(data()) == nullptr ||
4646
range->spilled() || top_start_block->IsDeferred() ||
47-
(!v8_flags.stress_turbo_late_spilling && !range->is_loop_phi())) {
47+
(!v8_flags.turbo_always_optimize_spills && !range->is_loop_phi())) {
4848
range->CommitSpillMoves(data(), spill_operand);
4949
return;
5050
}

src/flags/flag-definitions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1367,7 +1367,7 @@ DEFINE_BOOL_READONLY(opt, false,
13671367
#endif // V8_ENABLE_TURBOFAN
13681368

13691369
DEFINE_BOOL(
1370-
stress_turbo_late_spilling, false,
1370+
turbo_always_optimize_spills, true,
13711371
"optimize placement of all spill instructions, not just loop-top phis")
13721372

13731373
DEFINE_BOOL(turbo_wasm_address_reassociation, true,

0 commit comments

Comments
 (0)