RFR: 8267332: xor value should handle bounded values [v3]
Claes Redestad
redestad at openjdk.java.net
Thu May 20 22:01:11 UTC 2021
On Thu, 20 May 2021 21:50:46 GMT, Nils Eliasson <neliasso at openjdk.org> wrote:
>> src/hotspot/share/opto/addnode.cpp line 929:
>>
>>> 927: if ((t1i->_lo >= 0) &&
>>> 928: (t1i->_hi > 0) &&
>>> 929: (t1i->_hi <= max_power_of_2<jint>()) &&
>>
>> I think you could use `<= std::numeric_limits<T>::max()` as the upper bound condition, and use `(jint)(next_power_of_2((uint)t1i->_hi) - 1)` to produce the mask in an overflow-conscious way.
>
> max_power_of_2<jint>() is less than std::numeric_limits<T>::max().
>
> But I noticed I got the bounds wrong - is should be strictly less:
> t1i->_hi < max_power_of_2<jint>()
Right, that's why I widened to an `uint` (since `next_power_of_2((uint)jint::max())` is well-defined) then cast back to a `jint` after subtracting 1.
-------------
PR: https://git.openjdk.java.net/jdk/pull/4136
More information about the hotspot-compiler-dev
mailing list