RFR: 8267332: xor value should handle bounded values [v2]

Nils Eliasson neliasso at openjdk.java.net
Thu May 20 21:53:59 UTC 2021


On Thu, 20 May 2021 21:44:36 GMT, Claes Redestad <redestad at openjdk.org> wrote:

>> Nils Eliasson has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Fix bounds check
>
> 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>()

-------------

PR: https://git.openjdk.java.net/jdk/pull/4136


More information about the hotspot-compiler-dev mailing list