Integrated: 8350329: C2: Div looses dependency on condition that guarantees divisor not zero in counted loop after peeling

Roland Westrelin roland at openjdk.org
Mon May 19 11:10:58 UTC 2025


On Fri, 16 May 2025 08:28:20 GMT, Roland Westrelin <roland at openjdk.org> wrote:

> This is an issue similar to 8349139: the type of the iv phi of a
> counted loop is narrowed down so a `Div` node doesn't need a control
> input. The loop is then peeled. The `Div` in the loop body is
> guaranteed to be non zero only if it is actually executed so the `Div`
> is implicitly dependent on the zero trip guard. Then the loop looses
> its backedge and the `Div` freely floats. The `Div` instruction is
> scheduled above the zero trip guard and faults. Had the `Div` been
> control dependent on the zero trip guard, it wouldn't have
> executed. The fix, similar to 8349139 is to add a `CastII` on peeling
> to make the dependency between what's in the loop body and relies on
> the narrowed down type of the iv phi and the zero trip guard explicit.

This pull request has now been integrated.

Changeset: 26cb016b
Author:    Roland Westrelin <roland at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/26cb016b750963a4622985399130024792691984
Stats:     64 lines in 2 files changed: 62 ins; 0 del; 2 mod

8350329: C2: Div looses dependency on condition that guarantees divisor not zero in counted loop after peeling

Reviewed-by: thartmann, chagedorn

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

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


More information about the hotspot-compiler-dev mailing list