RFR: 8367341: C2: apply KnownBits and unsigned bounds to And / Or operations
    Quan Anh Mai 
    qamai at openjdk.org
       
    Wed Oct 15 08:16:14 UTC 2025
    
    
  
On Mon, 13 Oct 2025 12:23:13 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 96:
> 
>> 94:   KnownBits<U> _bits;
>> 95: 
>> 96: private:
> 
> Did you mean to drop the `private:` here? It also makes other things below public now...
Yes, we have a ton of ad-hoc `friend` declarations below, and I would need more for this patch. In addition, this prototype class is not meant to be used widely anyway, so it is better to just make it `public`.
> src/hotspot/share/opto/rangeinference.hpp line 152:
> 
>> 150: 
>> 151:   template <class CTP>
>> 152:   static bool int_type_is_equal(const CTP t1, const CTP t2) {
> 
> Out of curiosity: why the change `CT*` -> `CTP`?
It is so that we can use this for `TypeIntMirror`.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27618#discussion_r2431558521
PR Review Comment: https://git.openjdk.org/jdk/pull/27618#discussion_r2431559665
    
    
More information about the hotspot-compiler-dev
mailing list