RFR: 8356647: C2: Excessively strict assert in PhaseIdealLoop::do_unroll
Dean Long
dlong at openjdk.org
Mon May 19 23:22:52 UTC 2025
On Mon, 19 May 2025 06:43:38 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.
src/hotspot/share/opto/loopTransform.cpp line 1903:
> 1901: jlong trip_count = (limit_con - init_con + stride_m)/new_stride_con;
> 1902: // New trip count should satisfy next conditions.
> 1903: assert(trip_count > 0 && (julong)trip_count <= (julong)1 << (sizeof(juint)*BitsPerByte-1), "sanity");
Suggestion:
assert((julong)trip_count * 2 <= max_juint, "sanity");
This should catch negative values and any value that would make new_trip_count*2 below overflow.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25295#discussion_r2096599846
More information about the hotspot-compiler-dev
mailing list