On Thu, 17 Sep 2026 15:18:16 GMT, Kangcheng Xu <[email protected]> wrote:
>> Hi, >> >> This PR adds intrinsics to `Preconditions.checkFromToIndex()` and >> `Preconditions.checkFromIndexSize()` to produced optimized IR that uses >> `RangeCheck` node instead of implicit comparisons. >> `Preconditions.checkIndex()` is also refactored (without additional >> optimizations) to use the same helper function. >> >> Some common patterns where calling `checkFromToIndex` or >> `checkFromIndexSize` in a loop can have range checks in main loop eliminated >> completely and, therefore, enables empty loop removal. >> >> IR and correctness tests are included and passing. Additional tests on >> `Preconditions.checkIndex()` were also added. >> >> Thanks! >> >> --------- >> - [x] I confirm that I make this contribution in accordance with the >> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai). > > Kangcheng Xu has updated the pull request incrementally with one additional > commit since the last revision: > > explicit nullptr check, add type cast, add clarifications in comments src/hotspot/share/opto/library_call.cpp line 1392: > 1390: // 1) length >= 0 (non-negative guard) > 1391: // 2) from u< length (range check, RCE-hoistable, > encodes from >= 0 && from < length) > 1392: // 3) to - from - 1 u< length (range check, RCE-hoistable, > encodes from < to) I would explicitly state that `from < to` is not RCE-hoistable which is why this test is used instead. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/31138#discussion_r4079857514
