RFR: 8373999: C2: apply KnownBits and unsigned bounds to Add / Sub operations [v4]

Benoît Maillard bmaillard at openjdk.org
Thu Jan 15 08:38:58 UTC 2026


On Wed, 14 Jan 2026 13:36:14 GMT, Quan Anh Mai <qamai at openjdk.org> wrote:

>> src/hotspot/share/opto/rangeinference.hpp line 491:
>> 
>>> 489:       // min_bit >= 2 if and only if either:
>>> 490:       // - st1._bits._ones[i] == st2._bits._ones[i] == 1
>>> 491:       // - (st1._bits._ones[i] == 1 || st2._bits._ones[i] == 1) && ((min_bit & 1) == 0)
>> 
>> If I am not mistaken we could also write it this way, and I personally find this a bit more intuitive (and also more consistent with the subtraction case). And for the subsequent computations we could replace `|` by `^`. 
>> Suggestion:
>> 
>>       // - (st1._bits._ones[i] != st2._bits._ones[i]) && ((min_bit & 1) == 0)
>
> Yes you are right, that's a good idea.

Then we should probably also replace `|` by `^` in the subsequent calculations/expressions right? I have added suggestions for that.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/28897#discussion_r2693441539


More information about the hotspot-compiler-dev mailing list