RFR: 8364970: Redo JDK-8327381 by updating the CmpU type instead of the Bool type [v2]
Francisco Ferrari Bihurriet
fferrari at openjdk.org
Thu Aug 14 06:08:22 UTC 2025
On Wed, 13 Aug 2025 12:22:00 GMT, Francisco Ferrari Bihurriet <fferrari at openjdk.org> wrote:
>> Update looks good, thanks! I'll run some testing and report back again.
>>
>>> Could you already find some examples, where this change gives us an improved IR? If so, you could also add it as IR test.
>>
>> Just double-checking, were you able to find such a test which now improves the IR with the better type info and `CmpU` while we could not with the old code? Otherwise, you could also file a follow-up RFE.
>
> @chhagedorn
>> > Could you already find some examples, where this change gives us an improved IR? If so, you could also add it as IR test.
>>
>> Just double-checking, were you able to find such a test which now improves the IR with the better type info and `CmpU` while we could not with the old code? Otherwise, you could also file a follow-up RFE.
>
> Sorry for not replying that, I'm working on it.
>
> We were explicitly matching the `BoolNode` tests, so let's explore the tests we were previously discarding.
>
> For **case 1a**, we were explicitly matching `BoolTest::le`, but now `CmpUNode` has `TypeInt::CC_LE` reflecting the fact that `m & x ≤u m` is always true, so:
>
> | Test | Symbolic representation | Result | Improved IR |
> |:------------------:|:-----------------------:|:--------:|:-------------------------:|
> | `BoolTest::eq` | `m & x =u m` | unknown | no |
> | `BoolTest::ne` | `m & x ≠u m` | unknown | no |
> | **`BoolTest::le`** | **`m & x ≤u m`** | **true** | **no (old optimization)** |
> | `BoolTest::ge` | `m & x ≥u m` | unknown | no |
> | `BoolTest::lt` | `m & x <u m` | unknown | no |
> | `BoolTest::gt` | `m & x >u m` | false | yes |
>
> For **case 1b**, we were explicitly matching `BoolTest::lt`, but now `CmpUNode` has `TypeInt::CC_LT` reflecting the fact that `m & x <u m + 1` is always true (if `m ≠ -1`), so:
>
> | Test | Symbolic representation | Result if `m ≠ -1` | Improved IR |
> |:------------------:|:-----------------------:|:------------------:|:-------------------------:|
> | `BoolTest::eq` | `m & x =u m + 1` | false | yes |
> | `BoolTest::ne` | `m & x ≠u m + 1` | true | yes |
> | `BoolTest::le` | `m & x ≤u m + 1` | true | yes |
> | `BoolTest::ge` | `m & x ≥u m + 1` | false | yes |
> | **`BoolTest::lt`** | **`m & x <u m + 1`** | **true** | **no (old optimization)** |
> | `BoolTest::gt` | `m & x >u m + 1` | false | yes |
>
> I will work on adding IR tests for these cases.
>
> Regarding real-world use cases, we need to rule out `BoolTest::lt`, as it didn't improve for _case 1a_ and was alread...
> Thank you @franferrax for catching and addressing the inconsistent state. I neglected that in my original PR. I think it would be beneficial to include [your tables](https://github.com/openjdk/jdk/pull/26666#issuecomment-3183659818) of the two cases in the comments too. Thank you for the hard work.
@tabjy thanks for the suggestion, I added the tables in 32a7940b8eefe56c3aa603be65da7b32981d2ab7.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/26666#issuecomment-3187074888
More information about the hotspot-compiler-dev
mailing list