RFR: 8367341: C2: apply KnownBits and unsigned bounds to And / Or operations
    Emanuel Peter 
    epeter at openjdk.org
       
    Mon Oct 13 13:18:46 UTC 2025
    
    
  
On Mon, 13 Oct 2025 12:26:01 GMT, Emanuel Peter <epeter at openjdk.org> wrote:
>> Hi,
>> 
>> This PR improves the implementation of `AndNode/OrNode/XorNode::Value` by taking advantages of the additional information in `TypeInt`. The implementation is pretty straightforward. A clever trick is that by analyzing the negative and positive ranges of a `TypeInt` separately, we have better info for the leading bits. I also implement gtest unit tests to verify the correctness and monotonicity of the inference functions.
>> 
>> Please take a look and leave your reviews, thanks a lot.
>
> src/hotspot/share/opto/rangeinference.hpp line 192:
> 
>> 190: // inference from the Type infrastructure of the compiler. It also allows more flexibility with the
>> 191: // bit width of the integer type. As a result, it is more efficient to use for intermediate steps
>> 192: // of inference, as well as more flexible to perform testing on different integer types.
> 
> Would have been nice if we could have used the `TypeIntMirror` inside `TypeInt`, i.e. using composition. But sadly, we are already using fields from `TypeInt` directly everywhere, so not sure if that is very nice/easy.
Hmm, we also have the third class `TypeIntPrototype`. Do you think we really need all 3 classes?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27618#discussion_r2426204520
    
    
More information about the hotspot-compiler-dev
mailing list