RFR: 8315066: Add unsigned bounds and known bits to TypeInt/Long [v65]

Jatin Bhateja jbhateja at openjdk.org
Tue Jun 10 07:42:53 UTC 2025


On Mon, 9 Jun 2025 17:29:36 GMT, Quan Anh Mai <qamai at openjdk.org> wrote:

>> Hi,
>> 
>> This patch adds unsigned bounds and known bits constraints to TypeInt and TypeLong. This opens more transformation opportunities in an elegant manner as well as helps avoid some ad-hoc rules in Hotspot.
>> 
>> In general, a `TypeInt/Long` represents a set of values `x` that satisfies: `x s>= lo && x s<= hi && x u>= ulo && x u<= uhi && (x & zeros) == 0 && (x & ones) == ones`. These constraints are not independent, e.g. an int that lies in [0, 3] in signed domain must also lie in [0, 3] in unsigned domain and have all bits but the last 2 being unset. As a result, we must canonicalize the constraints (tighten the constraints so that they are optimal) before constructing a `TypeInt/Long` instance.
>> 
>> This is extracted from #15440 , node value transformations are left for later PRs. I have also added unit tests to verify the soundness of constraint normalization.
>> 
>> Please kindly review, thanks a lot.
>> 
>> Testing
>> 
>> - [x] GHA
>> - [x] Linux x64, tier 1-4
>
> Quan Anh Mai has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 83 commits:
> 
>  - Merge branch 'master' into unsignedbounds
>  - add more intn_t tests
>  - Emanuel's reviews
>  - alignment wording
>  - refinement
>  - refine the cases where there does not exist a result
>  - add some more sanity static_asserts
>  - intn_t refinements
>  - Emanuel's reviews
>  - Emanuel's reviews
>  - ... and 73 more: https://git.openjdk.org/jdk/compare/cae1fd33...ad6ac7cb

Great work @merykitty , it was a pleasure to study your patch and refresh some of low level details of bit level data flow analysis.

LGTM,

Best Regards

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

Marked as reviewed by jbhateja (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/17508#pullrequestreview-2912340763


More information about the hotspot-compiler-dev mailing list