RFR: 8315066: Add unsigned bounds and known bits to TypeInt/Long [v44]
Emanuel Peter
epeter at openjdk.org
Wed Feb 26 11:18:08 UTC 2025
On Fri, 14 Feb 2025 12:59:13 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 incrementally with one additional commit since the last revision:
>
> refine comments
Nice improvements @merykitty !
I think the "2. Formality" section is very strong now. I'll continue reviewing the rest soon.
src/hotspot/share/opto/rangeinference.cpp line 158:
> 156: bits at x > i have lower significance, and are thus irrelevant
> 157:
> 158: a.2. We have v satisfies bits, this is because:
Suggestion:
a.2. We know v satisfies bits, this is because:
src/hotspot/share/opto/rangeinference.cpp line 161:
> 159: v[x] satisfies bits for 0 <= x < i (according to 2.2 and 2.5)
> 160: v[i] satisfies bits:
> 161: According to 2.3 and 2.6, v[i] == 1 and zeros[i] == 0, v[i] does not violate
Suggestion:
According to 2.3 and 2.6, zeros[i] == 0 and v[i] == 1, v[i] does not violate
Keep the same order as the references.
src/hotspot/share/opto/rangeinference.cpp line 187:
> 185: bits at x > j have lower significance, and are thus irrelevant
> 186:
> 187: Which leads to r < lo, which contradicts that r >= lo
Suggestion:
Which leads to r < lo, which contradicts that r >= lo (according to definition of r)
It could be nice to define it more explicitly, and give the definition of `r` a title / name.
-------------
Changes requested by epeter (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/17508#pullrequestreview-2644060991
PR Review Comment: https://git.openjdk.org/jdk/pull/17508#discussion_r1971386552
PR Review Comment: https://git.openjdk.org/jdk/pull/17508#discussion_r1971390112
PR Review Comment: https://git.openjdk.org/jdk/pull/17508#discussion_r1971398511
More information about the hotspot-compiler-dev
mailing list