RFR: 8267332: xor value should handle bounded values [v3]
Claes Redestad
redestad at openjdk.java.net
Thu May 20 22:04:35 UTC 2021
On Thu, 20 May 2021 21:57:32 GMT, Claes Redestad <redestad at openjdk.org> wrote:
>> 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.
Another way of expressing the same in an overflow-conscious way (without type conversion) is `round_down_power_of_2(t1i->_hi) + (round_down_power_of_2(t1i->_hi) - 1)`
-------------
PR: https://git.openjdk.java.net/jdk/pull/4136
More information about the hotspot-compiler-dev
mailing list