RFR: 8365205: C2: Optimize popcount value computation using knownbits [v3]
Jatin Bhateja
jbhateja at openjdk.org
Thu Sep 11 12:16:49 UTC 2025
On Wed, 10 Sep 2025 16:03:10 GMT, Emanuel Peter <epeter at openjdk.org> wrote:
>>> @SirYwell @jatin-bhateja @merykitty I linked this issue here to the KnownBits RFE, to make sure we keep track of all KnownBits extensions. Can you please help me with linking any other RFEs that have already been filed or come up in the future? It would help track progress and avoid duplicate work.
>>
>> Current And Value Transforms :
>> - Constant folds - both inputs
>> - There are four possible cases for known bits extraction : -
>>
>> _lo _hi
>> <0 <0 : Possibility of finding common prefix and known ZERO and ONE bits among the common portion.
>> >=0 <0 : Not applicable scenario, since lower is greater than the upper bound.
>> <0 >=0 : No possibility of finding a common prefix b/w hi and lo bounds, thus no known bits exist.
>> >=0 >=0 : Possibility of finding common prefix and known ZERO and ONE bits among the common portion.
>>
>>
>> Existing value transforms and canonicalization should furnish known bits in applicable scenarios.
>>
>> For a full solution, we can add another rule to directly AND the known ZERO and ONE bits of participating inputs, and let canonicalization compute the resultant type and clean up existing handling in Value transforms and explicit constant folding
>
>> For a full solution, we can add another rule to directly AND the known ZERO and ONE bits of participating inputs, and let canonicalization compute the resultant type and clean up existing handling in Value transforms and explicit constant folding
>
> Yes, this is what we would end up with after https://bugs.openjdk.org/browse/JDK-8367341 . But I think currently, there is no good way to set / get bits directly.
>
> Using signed comparisons as you mentioned is only of limited help. But it is what we have for now.
> > testPopCountElisionInt1 and testPopCountElisionLong1 check for absence of PopCount IR nodes.
>
> @jatin-bhateja But there the clamps are with fixed constants. It would be nice if we also had some tests with randomized constants. We don't need IR tests for those, just result verification.
Hi @eme64, added a random bound test point.-
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27075#discussion_r2340528585
More information about the hotspot-compiler-dev
mailing list