RFR: 8324751: C2 SuperWord: Aliasing Analysis runtime check [v23]
Emanuel Peter
epeter at openjdk.org
Mon Aug 25 11:01:10 UTC 2025
On Mon, 25 Aug 2025 10:55:52 GMT, Emanuel Peter <epeter at openjdk.org> wrote:
>> TODO work that arose during review process / recent merges with master:
>>
>> - Vladimir asked for benchmark where predicate is disabled, only multiversioning. Show that peek performance is identical but compilation time a bit higher. Investigation ongoing.
>> - See if we can harden some of the IR rules in `TestAliasingFuzzer.java` after JDK-8356176. Probably file a follow-up RFE.
>>
>> ---------------
>>
>> This is a big patch, but about 3.5k lines are tests. And a large part of the VM changes is comments / proofs.
>>
>> I am adding a dynamic (runtime) aliasing check to the auto-vectorizer (SuperWord). We use the infrastructure from https://github.com/openjdk/jdk/pull/22016:
>> - Use the auto-vectorization `predicate` when available: we speculate that there is no aliasing, else we trap and re-compile without the predicate.
>> - If the predicate is not available, we use `multiversioning`, i.e. we have a `fast_loop` where there is no aliasing, and hence vectorization. And a `slow_loop` if the check fails, with no vectorization.
>>
>> --------------------------
>>
>> **Where to start reviewing**
>>
>> - `src/hotspot/share/opto/mempointer.hpp`:
>> - Read the class comment for `MemPointerRawSummand`.
>> - Familiarize yourself with the `MemPointer Linearity Corrolary`. We need it for the proofs of the aliasing runtime checks.
>>
>> - `src/hotspot/share/opto/vectorization.cpp`:
>> - Read the explanations and proofs above `VPointer::can_make_speculative_aliasing_check_with`. It explains how the aliasing runtime check works.
>>
>> - `src/hotspot/share/opto/vtransform.hpp`:
>> - Understand the difference between weak and strong edges.
>>
>> If you need to see some examples, then look at the tests:
>> - `test/hotspot/jtreg/compiler/loopopts/superword/TestAliasing.java`: simple array cases. IR rules that check for vectors and in somecases if we used multiversioning.
>> - `test/micro/org/openjdk/bench/vm/compiler/VectorAliasing.java`: the miro-benchmarks I show below. Simple array cases.
>> - `test/hotspot/jtreg/compiler/loopopts/superword/TestMemorySegmentAliasing.java`: a bit advanced, but similar cases.
>> - `test/hotspot/jtreg/compiler/loopopts/superword/TestAliasingFuzzer.java`: very large and rather compliex. Generates random loops, some with and some without aliasing at runtime. IR verification, but mostly currently only for array cases, MemorySegment cases have some issues (see comments).
>> --------------------------
>>
>> **Details**
>>
>> Most fundamentally:
>> - I had to...
>
> Emanuel Peter has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 217 commits:
>
> - Merge branch 'master' into JDK-8324751-Aliasing-Analysis-RTC
> - improve tests a little
> - add test for related report for JDK-8365982
> - add test for related report for JDK-8360204
> - add test for related report for JDK-8359688
> - rm IR rule that checks multiversioning, rare cases fail due to RCE
> - disable flag if not possible
> - more documentation for Vladimir
> - improve benchmark
> - fix tests after master integration of JDK-8342692 and JDK-8356176
> - ... and 207 more: https://git.openjdk.org/jdk/compare/45726a1f...a36e3f7a
I just merged with master again, and will run our internal performance testing again, just to be sure.
It was all fine a few weeks ago, and I had even reported a performance improvement:
<img width="2540" height="232" alt="image" src="https://github.com/user-attachments/assets/1d250e2e-8b68-4d9e-9474-2ff7af97c4a2" />
Let's hope I can reproduce that result 🙏
-------------
PR Comment: https://git.openjdk.org/jdk/pull/24278#issuecomment-3219796170
More information about the hotspot-compiler-dev
mailing list