RFR: 8315066: Add unsigned bounds and known bits to TypeInt/Long [v57]
Emanuel Peter
epeter at openjdk.org
Fri May 2 09:41:03 UTC 2025
On Fri, 2 May 2025 08:55:45 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:
>
> Emanuel's reviews
And a few comments about the gtests :)
test/hotspot/gtest/opto/test_rangeinference.cpp line 113:
> 111: for (int i = 0; i < parameters; i++) {
> 112: S a = uniform_random<U>();
> 113: S b = uniform_random<U>();
How expensive would it be to run a few more here?
test/hotspot/gtest/utilities/test_intn_t.cpp line 38:
> 36: if (i < intn_t<n>::max) {
> 37: ASSERT_TRUE(intn_t<n>(i) < intn_t<n>(i + 1));
> 38: }
How about a check for the overflow case?
test/hotspot/gtest/utilities/test_intn_t.cpp line 51:
> 49: test_intn_t<7>();
> 50: test_intn_t<8>();
> 51: }
And how about some tests for `uintn_t`?
-------------
PR Review: https://git.openjdk.org/jdk/pull/17508#pullrequestreview-2811578117
PR Review Comment: https://git.openjdk.org/jdk/pull/17508#discussion_r2071352975
PR Review Comment: https://git.openjdk.org/jdk/pull/17508#discussion_r2071360729
PR Review Comment: https://git.openjdk.org/jdk/pull/17508#discussion_r2071361519
More information about the hotspot-compiler-dev
mailing list