RFR: 8367341: C2: apply KnownBits and unsigned bounds to And / Or operations
Quan Anh Mai
qamai at openjdk.org
Wed Oct 15 08:22:22 UTC 2025
On Mon, 13 Oct 2025 12:29: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 199:
>
>> 197: S _hi;
>> 198: U _ulo;
>> 199: U _uhi;
>
> Why not use `RangeInt`?
These are the mirrors of `TypeInt` and `TypeLong` so they need to be structurally similar to `TypeInt` and `TypeLong`.
> src/hotspot/share/opto/rangeinference.hpp line 218:
>
>> 216: bool contains(U u) const;
>> 217: bool contains(const TypeIntMirror& o) const;
>> 218: bool operator==(const TypeIntMirror& o) const;
>
> Could we limit this to `DEBUG_ONLY`?
Maybe, it disables these gtest in product builds, however. What do you think?
> src/hotspot/share/opto/rangeinference.hpp line 221:
>
>> 219:
>> 220: template <class T>
>> 221: TypeIntMirror cast() const;
>
> Can you explain what this casting method is for?
This is to mimic the behaviour when we do `t1->meet(t2)->cast<TypeInt>()`.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27618#discussion_r2431572634
PR Review Comment: https://git.openjdk.org/jdk/pull/27618#discussion_r2431574484
PR Review Comment: https://git.openjdk.org/jdk/pull/27618#discussion_r2431578081
More information about the hotspot-compiler-dev
mailing list