On Thu, 17 Sep 2026 15:13:51 GMT, Kangcheng Xu <[email protected]> wrote:
>> src/hotspot/share/opto/library_call.cpp line 1434:
>>
>>> 1432: Node* to_minus_one = _gvn.transform(SubNode::make(to,
>>> _gvn.integercon(1, bt), bt));
>>> 1433: Node* casted_to_minus_one = insert_unsigned_range_check(*this,
>>> to_minus_one, casted_length, bt);
>>> 1434: if (casted_to_minus_one == nullptr) {
>>
>> Couldn't you cast `to` to `[1..length-1]` here?
>
> I believe you mean `[1, length]`? (i.e., `to <= length`) I added a cast node
> with type `[max(1, old_lo), min(length_hi, old_hi)]` which only narrows
> bounds instead widening it.
The type of the cast node is the intersection of the type of the input of the
cast node and the type stored in the cast node, i.e. the max/min happens
automatically (see `Value` method of cast nodes). I would remove them to keep
things clearer.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/31138#discussion_r4079815258