RFR: 8365205: C2: Optimize popcount value computation using knownbits [v3]

Jatin Bhateja jbhateja at openjdk.org
Wed Sep 10 16:00:37 UTC 2025


On Wed, 10 Sep 2025 14:26:31 GMT, Hannes Greule <hgreule at openjdk.org> wrote:

>> testPopCountElisionInt1 and testPopCountElisionLong1 check for absence of PopCount IR nodes.
>
> I think Or and And nodes aren't updated to make use if KnownBits themselves (that generally makes testing based on KnownBits a bit difficult).

> @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

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

PR Review Comment: https://git.openjdk.org/jdk/pull/27075#discussion_r2337215333


More information about the hotspot-compiler-dev mailing list