RFR: 8365205: C2: Optimize popcount value computation using knownbits [v11]
Chen Liang
liach at openjdk.org
Thu Sep 25 21:27:45 UTC 2025
On Fri, 19 Sep 2025 20:44:54 GMT, Jatin Bhateja <jbhateja at openjdk.org> wrote:
>> This patch optimizes PopCount value transforms using KnownBits information.
>> Following are the results of the micro-benchmark included with the patch
>>
>>
>>
>> System: 13th Gen Intel(R) Core(TM) i3-1315U
>>
>> Baseline:
>> Benchmark Mode Cnt Score Error Units
>> PopCountValueTransform.LogicFoldingKerenLong thrpt 2 215460.670 ops/s
>> PopCountValueTransform.LogicFoldingKerenlInt thrpt 2 294014.826 ops/s
>>
>> Withopt:
>> Benchmark Mode Cnt Score Error Units
>> PopCountValueTransform.LogicFoldingKerenLong thrpt 2 389978.082 ops/s
>> PopCountValueTransform.LogicFoldingKerenlInt thrpt 2 417261.583 ops/s
>>
>>
>> Kindly review and share your feedback.
>>
>> Best Regards,
>> Jatin
>
> Jatin Bhateja has updated the pull request incrementally with one additional commit since the last revision:
>
> Update countbitsnode.cpp
A suggestion, we might do this as a later RFE.
src/hotspot/share/opto/countbitsnode.cpp line 124:
> 122: // From the definition of KnownBits, we know:
> 123: // zeros: Indicates which bits must be 0: zeros[i]=1 -> t[i]=0
> 124: // ones: Indicates which bits must be 1: ones[i]=1 -> t[i]=1
I don't think we should duplicate the information available in rangeinference.hpp - we should enhance the documentation there, such as noting `~zeros` is the number where the maximum number of bits are set to 1, to help comprehension.
If we know `ones` is `min_ones` and `~zeros` is `max_ones`, we can easily derive that `pop_count(ones) <= pop_count(t) <= pop_count(~zeros)`
-------------
PR Review: https://git.openjdk.org/jdk/pull/27075#pullrequestreview-3269507322
PR Review Comment: https://git.openjdk.org/jdk/pull/27075#discussion_r2380355747
More information about the hotspot-compiler-dev
mailing list