Integrated: 8372302: C2: IGVN verification fails because ModXNode::Ideal creates unused intermediate nodes

Benoît Maillard bmaillard at openjdk.org
Mon Jan 12 08:04:10 UTC 2026


On Tue, 25 Nov 2025 10:35:36 GMT, Benoît Maillard <bmaillard at openjdk.org> wrote:

> This PR addresses a failure in IGVN verification with `ModI` and `ModL` nodes.
> 
> In `ModeXNode::Ideal`, we have code to optimize a modulo expression by expressing it in terms of other operations. There are actually two distinct cases, one where the divisor is a constant and is equal to `modulo 2^k-1` for some integer `k`, and a more general case where other transformations do not succeed. Because these transformations involve creating several new nodes (sometimes in a loop) and calling `phase->transform(...)` on them, we want to avoid accidentally triggering optimizations on the "unfinished" state of the subgraph. For this, we create a temporary dummy node and add edges to the nodes being constructed.
> 
> There are some execution paths where the node is not destroyed before `Ideal` returns, and this creates issues during IGVN verification, as the verification code checks if the number of nodes has changed after having called `Ideal` on a given node and not expecting changes.
> 
> The path in question is when we exit because the divisor is a constant and is the minimum value:
> https://github.com/openjdk/jdk/blob/c19b12927d2ac901ec8ccaa2de5897ee4c47af56/src/hotspot/share/opto/divnode.cpp#L1146-L1147
> 
> The zero case does not cause problems (this seems to be because it would hide behind a `div0_check` anyway).
> 
> The fix is simply to only create the temporary node when it is needed, and thus avoiding returning without destroying it.
> 
> ### Testing
> - [x] [GitHub Actions](TODO)
> - [x] tier1-4, plus some internal testing
> 
> Thank you for reviewing!

This pull request has now been integrated.

Changeset: 49040462
Author:    Benoît Maillard <bmaillard at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/49040462f3d2761435cded1bd8898d0c6b16fc02
Stats:     70 lines in 2 files changed: 63 ins; 4 del; 3 mod

8372302: C2: IGVN verification fails because ModXNode::Ideal creates unused intermediate nodes

Reviewed-by: epeter, qamai

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

PR: https://git.openjdk.org/jdk/pull/28488


More information about the hotspot-compiler-dev mailing list