RFR: 8324751: C2 SuperWord: Aliasing Analysis runtime check [v11]

Emanuel Peter epeter at openjdk.org
Tue Aug 19 16:45:48 UTC 2025


On Tue, 19 Aug 2025 15:09:26 GMT, Vladimir Kozlov <kvn at openjdk.org> wrote:

>> I described it at the top of the PR:
>>> 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.
>> 
>> So if only one of them is available, we expect vectorization - at least as long as the check never fails. If we only have the predicate and not multiversioning, and the predicate fails, then we will never get a slow-loop.
>> 
>> But sure, I can run some sanity benchmarking with only multiversioning and predicate disabled. I expect the peek performance to be identical, but compilation time will be slightly higher because we also always compile the slow-loop even if not needed.
>
> I mean, it should be in code's comments. And, yes please run benchmarks with different configuration.

The patch already adds these comments:

- `predicates.hpp`
  - https://github.com/openjdk/jdk/pull/24278/files#diff-d3883ecef2a7ed7fecf2f7b3b7d60c898b97d4199717552ecd52c3973e298a68R88-R102
  - `VTransform::apply_speculative_aliasing_runtime_checks` uses pre-existing `add_speculative_check`

Before the patch, we already have:
- `add_speculative_check`: I think it reads quite clearly, but it does not have any good descriptions. It calls:
  - `create_new_if_for_predicate`: no mention about multiversioning... but predicates apply to non auto-vec uses, so it should probably not be placed there.
  - `create_new_if_for_multiversion`: does not mention mention much. I'll add a link to `maybe_multiversion_for_auto_vectorization_runtime_checks` where there is more documentation.
- `PhaseIdealLoop::maybe_multiversion_for_auto_vectorization_runtime_checks` mentions that we only multiversion if there is no predicate.

I'm adding some more documentation and cross-links.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/24278#discussion_r2285801543


More information about the hotspot-compiler-dev mailing list