RFR: 8364970: Redo JDK-8327381 by updating the CmpU type instead of the Bool type [v2]
Francisco Ferrari Bihurriet
fferrari at openjdk.org
Wed Aug 13 12:24:16 UTC 2025
On Wed, 13 Aug 2025 07:05:51 GMT, Christian Hagedorn <chagedorn at openjdk.org> wrote:
>> Francisco Ferrari Bihurriet has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Apply code review suggestions and add JBS to test
>
> 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 already optimized in old code for _case 1b_.
I've found some possible candidates but haven't fully analyzed them yet:
* [Array construction of `new byte[FastAllocateSizeLimit & x]`](https://github.com/openjdk/jdk/blob/jdk-26+9/src/hotspot/share/opto/graphKit.cpp#L3820-L3821) with _case 1a_
* [Switch jump tables](https://github.com/openjdk/jdk/blob/jdk-26+9/src/hotspot/share/opto/parse2.cpp#L829-L830) with _case 1b_
* 8 more code searches ([A](https://github.com/openjdk/jdk/blob/jdk-26+9/src/hotspot/share/opto/graphKit.cpp#L3939-L3940), [B](https://github.com/openjdk/jdk/blob/jdk-26+9/src/hotspot/share/opto/library_call.cpp#L3449-L3450), [C](https://github.com/openjdk/jdk/blob/jdk-26+9/src/hotspot/share/opto/library_call.cpp#L3869-L3870), [D](https://github.com/openjdk/jdk/blob/jdk-26+9/src/hotspot/share/opto/parse2.cpp#L736-L737), [E](https://github.com/openjdk/jdk/blob/jdk-26+9/src/hotspot/share/opto/parse2.cpp#L829-L830), [F](https://github.com/openjdk/jdk/blob/jdk-26+9/src/hotspot/share/opto/subnode.cpp#L1650-L1651), [G](https://github.com/openjdk/jdk/blob/jdk-26+9/src/hotspot/share/opto/subnode.cpp#L1677-L1678), [H](https://github.com/openjdk/jdk/blob/jdk-26+9/src/hotspot/share/opto/subnode.cpp#L1680-L1681))
* 3 more possible indirect matches ([I](https://github.com/openjdk/jdk/blob/jdk-26+9/src/hotspot/share/opto/loopopts.cpp#L2944-L2947), [J](https://github.com/openjdk/jdk/blob/jdk-26+9/src/hotspot/share/opto/subnode.cpp#L1596-L1597), [K](https://github.com/openjdk/jdk/blob/jdk-26+9/src/hotspot/share/opto/subnode.cpp#L1601-L1602))
-------------
PR Comment: https://git.openjdk.org/jdk/pull/26666#issuecomment-3183659818
More information about the hotspot-compiler-dev
mailing list