RFR: 8365205: C2: Optimize popcount value computation using knownbits [v9]
Jatin Bhateja
jbhateja at openjdk.org
Fri Sep 19 09:49:18 UTC 2025
On Fri, 19 Sep 2025 09:32:30 GMT, Emanuel Peter <epeter at openjdk.org> wrote:
>> test/hotspot/jtreg/compiler/intrinsics/TestPopCountValueTransforms.java line 54:
>>
>>> 52: static final long rand_bndL2 = G.longs().next();
>>> 53: static final long rand_popcL1 = G.uniformLongs(0, 32).next();
>>> 54: static final long rand_popcL2 = G.uniformLongs(0, 32).next();
>>
>> Why did you limit the range for longs to 32? Can it not go up to 64?
>> I asked for an explanation (in a code comment) of those that you restrict here, which you have not done, and just "resolved" it instead:
>> https://github.com/openjdk/jdk/pull/27075#discussion_r2351166568
>
> If you do restrict it, then at least go over the range a little bit. Why?
> You check `Integer.bitCount(num) < rand_popcI2`. The max value you get here is 32, so we could never get a constant folding case for the range `0..32`. Maybe that is ok, but we potentially miss a chance to find something we did not even anticipate.
>
> That is why I would recommend **not** to constrain the values, unless you really have a good reason and write it down in a code comment.
> Why did you limit the range for longs to 32? Can it not go up to 64? I asked for an explanation (in a code comment) of those that you restrict here, which you have not done, and just "resolved" it instead: [#27075 (comment)](https://github.com/openjdk/jdk/pull/27075#discussion_r2351166568)
A silly typo, so no explanation :-) enjoy your break :-)
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27075#discussion_r2362345323
More information about the hotspot-compiler-dev
mailing list