RFR: 8347499: C2: Make `PhaseIdealLoop` eliminate more redundant safepoints in loops [v4]
Qizheng Xing
qxing at openjdk.org
Tue Oct 14 06:42:07 UTC 2025
> In `PhaseIdealLoop`, `IdealLoopTree::check_safepts` method checks if any call that is guaranteed to have a safepoint dominates the tail of the loop. In the previous implementation, `check_safepts` would stop if it found a local non-call safepoint. At this time, if there was a call before the safepoint in the dom-path, this safepoint would not be eliminated.
>
> <img width="353" alt="loop-safepoint" src="https://github.com/user-attachments/assets/c220e103-aaba-4e3f-98ac-1ddb6465c309" />
>
> This patch changes the behavior of `check_safepts` to not stop when it finds a non-local safepoint. This makes simple loops with one method call ~3.8% faster (on aarch64).
>
>
> Benchmark Mode Cnt Score Error Units
> LoopSafepoint.loopVar avgt 15 208296.259 ± 1350.409 ns/op # baseline
> LoopSafepoint.loopVar avgt 15 200692.874 ± 616.770 ns/op # this patch
>
>
> Testing: tier1-2 on x86_64 and aarch64.
Qizheng Xing has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains five additional commits since the last revision:
- Merge branch 'master' into enhance-loop-safepoint-elim
- Improve documentation comments
- Merge branch 'master' into enhance-loop-safepoint-elim
- Add IR test and microbench.
- Make `PhaseIdealLoop` eliminate more redundant safepoints in loops.
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/23057/files
- new: https://git.openjdk.org/jdk/pull/23057/files/1a216046..ba6e7e79
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=23057&range=03
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=23057&range=02-03
Stats: 1031881 lines in 13321 files changed: 545175 ins; 398869 del; 87837 mod
Patch: https://git.openjdk.org/jdk/pull/23057.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/23057/head:pull/23057
PR: https://git.openjdk.org/jdk/pull/23057
More information about the hotspot-compiler-dev
mailing list