RFR: 8356647: C2: Excessively strict assert in PhaseIdealLoop::do_unroll [v3]

Christian Hagedorn chagedorn at openjdk.org
Mon May 26 06:52:53 UTC 2025


On Fri, 23 May 2025 08:09:36 GMT, Marc Chevalier <mchevalier at openjdk.org> wrote:

>> This assert seems a bit too tight. See the JBS issue to check the math: the bound of `trip_count` should be `<= 2^31`, while the current bound is ` < (julong)max_juint/2` = floor((2^32-1)/2) = (2^32-2) / 2 = 2^31-1.
>
> Marc Chevalier has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Comments

src/hotspot/share/opto/loopTransform.cpp line 1922:

> 1920:     // Let's check we are in a surprise-free situation, that should be the only one reachable
> 1921:     // here. => old_trip_count was set, is reliable, and is small enough to be sure that `stride_con`
> 1922:     // will also be small enough, and no overflow risk.

Can't we just say that the old trip count is only set as exact in `compute_trip_count()` if it is less than `max_juint` and otherwise, it's inexact and we don't enter this path? You could also mention that adding `stride_m` is then overflow safe.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25295#discussion_r2106667315


More information about the hotspot-compiler-dev mailing list