RFR: 8367341: C2: apply KnownBits and unsigned bounds to And / Or operations [v2]
    Quan Anh Mai 
    qamai at openjdk.org
       
    Wed Oct 15 15:33:01 UTC 2025
    
    
  
On Wed, 15 Oct 2025 12:08:23 GMT, Emanuel Peter <epeter at openjdk.org> wrote:
>> Quan Anh Mai has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Emanuel's reviews
>
> src/hotspot/share/opto/rangeinference.hpp line 358:
> 
>> 356:       U<CTP> ulo = std::numeric_limits<U<CTP>>::min();
>> 357:       // The unsigned value of the result of 'and' is always not greater than both of its inputs
>> 358:       // since there is no position at which the bit is 1 in the result and 0 in either input
> 
> That does not sound correct.
> 
> We could have ranges `0..0b1000` for both. But then both values are `0b0010`, and so the result is `0b0010`, which is a 1 at a position where both `uhi` values had zeros.
> 
> I think you need to talk about leading zeros somehow.
No this is not about the range, but about the value in an operation. I.e. If `z = x & y` then `z u<= x && z u<= y`. This leads to the fact that the upper bound of `z` is not larger than the upper bounds of `x` and `y`.
> src/hotspot/share/opto/rangeinference.hpp line 372:
> 
>> 370:       S<CTP> hi = std::numeric_limits<S<CTP>>::max();
>> 371:       // The unsigned value of the result of 'or' is always not less than both of its inputs since
>> 372:       // there is no position at which the bit is 0 in the result and 1 in either input
> 
> Same issue here as above
Same here, if `z = x | y` then `z u>= x && z u>= y`. This means that the lower bound of `z` is not smaller than the lower bounds of `x` and `y`.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27618#discussion_r2433035783
PR Review Comment: https://git.openjdk.org/jdk/pull/27618#discussion_r2433040171
    
    
More information about the hotspot-compiler-dev
mailing list