RFR: 8356084: C2: Data is wrongly rewired to Initialized Assertion Predicates instead of Template Assertion Predicates
Christian Hagedorn
chagedorn at openjdk.org
Fri May 2 14:18:57 UTC 2025
Before the Assertion Predicate refactorings, we rewired data dependencies either to the newly created Initialized Assertion Predicates (for Loop Peeling) or to the zero trip guard (for main and post loops). Both was incomplete when we further split a loop - we missed to update these data dependencies accordingly.
Now that the (almost) complete Assertion Predicate fix is in with [JDK-8350577](https://bugs.openjdk.org/browse/JDK-8350577), we are now finally able to fix this by always rewiring the data dependencies to the Template Assertion Predicates which will be kept until either no more loop splitting can be done for a loop or until loop opts are over.
We could have already fixed that with JDK-8350577 but it was simply missed. As an intermediate solution, we always rewired the data dependencies to the Initialized Assertion Predicates which only worked in some cases when the Initialized Assertion Predicates were folded away: They ended up at the Template Assertion Predicates above and from there we could update the data dependencies further. But if that did not happen, we could not find these data dependencies at the Template Assertion Predicates and failed to further update them when the loop was split again. As a result, we could perform some loads too early and crash (not observable, though).
How we could end up with such a crash is described in the newly added regression test `testPeelingThreeTimesDataUpdate()`. Here is a snippet from the graph after applying Loop Peeling several times without the patch:

All `LoadN` data dependencies are piled up at an Initialized Assertion Predicate from where we can no longer update them in further loop splitting optimizations because we only look at Template Assertion Predicates for that. By correctly rewiring the data dependencies to Template Assertion Predicates, we fix this which is proposed with this patch.
This was found by a new stress peeling mode ([JDK-8355488](https://bugs.openjdk.org/browse/JDK-8355488)) @marc-chevalier
is currently working on. I was able to come up with a reproducer that does not use the new stressing but it shows that the new stressing is useful in finding hard to discover bugs.
Thanks,
Christian
-------------
Commit messages:
- 8356084: C2: Data is wrongly rewired to Initialized Assertion Predicates instead of Template Assertion Predicates
Changes: https://git.openjdk.org/jdk/pull/25007/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=25007&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8356084
Stats: 94 lines in 3 files changed: 79 ins; 1 del; 14 mod
Patch: https://git.openjdk.org/jdk/pull/25007.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/25007/head:pull/25007
PR: https://git.openjdk.org/jdk/pull/25007
More information about the hotspot-compiler-dev
mailing list