RFR: 8350756: C2 SuperWord Multiversioning: remove useless slow loop when the fast loop disappears
Emanuel Peter
epeter at openjdk.org
Tue Mar 4 07:50:39 UTC 2025
@rwestrel asked me for this here:
https://github.com/openjdk/jdk/pull/22016#issuecomment-2684365921
The idea: an unused `multiversion_if` (i.e. one where the `slow_loop` is still delayed, i.e. where the `fast_loop` has not yet added a runtime-check to the `multiversion_if`) can be constant-folded if the main `fast_loop` disappears. Because at that point we know that we will never add a new condition to the `multiversion_if`, and it will constant fold to true (towards the `fast_loop`) after loop-opts anyway.
It also seems to fix a bug, where all multiversioned loops (fast / slow, pre/main/post) disappear, and then we are left with a if-diamond with the multiversion_if. This then hits assertion code in `PhaseIdealLoop::conditional_move`. This issue is also addressed with this patch here. I adjusted the code around that assert slightly to give better reporting and ensure we bail out of the optimization if we see an unexpected pattern.
-------------
Commit messages:
- fix assert for VerifyLoopOpts
- whitespace
- added test
- improve assert
- JDK-8350756
Changes: https://git.openjdk.org/jdk/pull/23865/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=23865&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8350756
Stats: 156 lines in 6 files changed: 153 ins; 0 del; 3 mod
Patch: https://git.openjdk.org/jdk/pull/23865.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/23865/head:pull/23865
PR: https://git.openjdk.org/jdk/pull/23865
More information about the hotspot-compiler-dev
mailing list