RFR: 8315066: Add unsigned bounds and known bits to TypeInt/Long [v54]

Quan Anh Mai qamai at openjdk.org
Thu May 1 10:48:47 UTC 2025


On Thu, 1 May 2025 08:56:30 GMT, Emanuel Peter <epeter at openjdk.org> wrote:

>> src/hotspot/share/opto/rangeinference.cpp line 670:
>> 
>>> 668:   if (i1 == t2 || t2 == Type::TOP) {
>>> 669:     return i1;
>>> 670:   }
>> 
>> Not sure if I got this right, I'm not fully understanding what the `dual` flag does here yet.
>> Is this correct?
>> `meet = intersection` - `dual = false`
>> `join = union` - `dual = true`
>> 
>> So if `i1 == t2`, then we can return `i1` in both cases, as it is both the intersection and union.
>> But if `t2 == Type::TOP`, and `i1` is not TOP, then `i1` is not the intersection.
>> 
>> What am I missing?
>
> If this is  indeed a bug, we need a test case to catch it :)

No, the subset relation is only reversed in the set of all `CT` instances. In the overall `Type` hierarchy it is still the same, we are trying to find the union of the arguments. If you try to change it to `return dual ? t2 : i1` you would be hit with `=== Meet Not Symmetric ===` errors everywhere :) Similarly, that is why when the 2 arguments are of different kind the result is always `Type::BOTTOM`.

>> src/hotspot/share/opto/rangeinference.cpp line 678:
>> 
>>> 676:                                          {MIN2(i1->_ulo, i2->_ulo), MAX2(i1->_uhi, i2->_uhi)},
>>> 677:                                          {i1->_bits._zeros & i2->_bits._zeros, i1->_bits._ones & i2->_bits._ones}},
>>> 678:                   MAX2(i1->_widen, i2->_widen), false);
>> 
>> Ok, this looks like a union. And below like a intersection.
>
> Why do you handle the `widen` differently here?

Because the join of 2 widens should be the smaller value and the meet of 2 widens should be the larger one.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/17508#discussion_r2070140871
PR Review Comment: https://git.openjdk.org/jdk/pull/17508#discussion_r2070141428


More information about the hotspot-compiler-dev mailing list