Integrated: 8371146: C2 SuperWord: VTransform::add_speculative_check uses pre_init that is pinned after Auto_Vectorization_Check, leading to bad graph
Emanuel Peter
epeter at openjdk.org
Wed Nov 26 15:02:09 UTC 2025
On Fri, 21 Nov 2025 09:56:02 GMT, Emanuel Peter <epeter at openjdk.org> wrote:
> **Analysis**
>
> This is a regression of [JDK-8324751](https://bugs.openjdk.org/browse/JDK-8324751) / https://github.com/openjdk/jdk/pull/24278.
>
> The aliasing runtime check happens before the pre-loop. The values needed for the aliasing runtime check thus need to be available not just at the pre-loop, but even earlier: already at the aliasing check.
>
> Sadly, so far we only ever checked for `is_pre_loop_invariant`, and not `is_available_for_speculative_check`. We now found an example with the fuzzer that has a `pre_init` value that is pinned after the aliasing runtime check but before the pre-loop. Thus it passed the checks, and then created a bad graph (cyclic path, think "use before definition").
>
> This a very rare case. Getting the ctrl pinned after the aliasing runtime check but before the pre-loop requires some very specific order of loop-opts, of unroll/pre-main-post/peeling etc. But it can happen, and so we must handle it right.
>
> Solution: check for the stronger condition `is_available_for_speculative_check`.
>
> **Future Work**
>
> We should improve the debug printing when aliasing checks cannot be inserted. Currently the tag `SW_REJECTIONS` is a bit messy, we should fix that up. But it would be too many changes for this bug fix here.
>
> **Details**
>
> During `SuperWord`, we want to insert the aliasing runtime check above `687 ParsePredicate` which is annotated with `#Auto_Vectorization_Check`. For this, we require the `pre_init` value: `1244 AddI`. Sadly, this value is pinned lower down.
> <img width="1488" height="1204" alt="image" src="https://github.com/user-attachments/assets/cbbe1e67-a261-4e29-85de-b99a2f552d66" />
>
> So when we insert the aliasing runtime check, we create a bad (circular) graph:
> <img width="1480" height="1206" alt="image" src="https://github.com/user-attachments/assets/06f0f13c-2005-458a-bdda-6fa07e4321e2" />
This pull request has now been integrated.
Changeset: e3a08558
Author: Emanuel Peter <epeter at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/e3a085581bfa70437b73d4b0527a084e0c5c9aac
Stats: 164 lines in 3 files changed: 155 ins; 0 del; 9 mod
8371146: C2 SuperWord: VTransform::add_speculative_check uses pre_init that is pinned after Auto_Vectorization_Check, leading to bad graph
Reviewed-by: roland, chagedorn
-------------
PR: https://git.openjdk.org/jdk/pull/28449
More information about the hotspot-compiler-dev
mailing list