RFR: 8341697: C2: Register allocation inefficiency in tight loop

Quan Anh Mai qamai at openjdk.org
Fri Oct 11 15:54:47 UTC 2024


Hi,

This patch improves the spill placement in the presence of loops. Currently, when trying to spill a live range, we will create a `Phi` at the loop head, this `Phi` will then be spilt inside the loop body, and as the `Phi` is `UP` (lives in register) at the loop head, we need to emit an additional reload at the loop back-edge block. This introduces loop-carried dependencies, greatly reduces loop throughput. My proposal is that if a node is not reassigned inside a loop, and will be spilt there, we spill it eagerly at the loop entry instead. This can lead to more reload inside the loop, but as the loop-carried dependencies are eliminated, a load is negligible.

Please take a look and leave your reviews, thanks a lot.

-------------

Commit messages:
 - add benchmark
 - don't eagerly spill if we are reassigned anyway
 - eagerly spill a node in the loop entry

Changes: https://git.openjdk.org/jdk/pull/21472/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=21472&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8341697
  Stats: 87 lines in 3 files changed: 81 ins; 3 del; 3 mod
  Patch: https://git.openjdk.org/jdk/pull/21472.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/21472/head:pull/21472

PR: https://git.openjdk.org/jdk/pull/21472


More information about the hotspot-compiler-dev mailing list