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

Tobias Hartmann thartmann at openjdk.org
Fri May 16 13:19:55 UTC 2025


On Fri, 16 May 2025 12:45:16 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.
>
> Roland Westrelin has updated the pull request incrementally with one additional commit since the last revision:
> 
>   review

Marked as reviewed by thartmann (Reviewer).

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

PR Review: https://git.openjdk.org/jdk/pull/25262#pullrequestreview-2846609906


More information about the hotspot-compiler-dev mailing list