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

Quan Anh Mai qamai at openjdk.org
Mon Sep 30 15:06:46 UTC 2024


On Wed, 18 Sep 2024 19:00:12 GMT, Dean Long <dlong at openjdk.org> wrote:

>> No we can't, consider `TypeInt::NON_ZERO`. It would have `_lo = min_jint`, `_hi = max_jint`, `_zeros = 0`, `_ones = 0`. Which make it impossible to distinguish from `TypeInt::INT` without unsigned bounds.
>
> Ignoring the unsigned issue for a moment, and going back to Dual, if we had the concept of Complement, we could represent NON_ZERO as the complement of 0 <= x <= 0, which would be x > 0 || x < 0.  In general, the complement of lo <= x <= hi would be x > hi || x < lo, in contrast to the dual, which I believe is defined as the non-intuitive hi <= x <= lo.  I think complement would allow us to represent more complicated expressions, such as !(x>=lo && x<=hi).
> 
> If both dual and complement can be used to map between join and meet, then of the two complement seems more attractive and intuitive.  But maybe there is another reason we need dual than I'm missing.

The issue then would be the mixture of complementary and non-complementary types. The bounds of a `TypeInt` is the union of 2 intervals `[lo, uhi]` and `[ulo, hi]`, while those of a complementary would be 4, `[min_value, lo]`, `[uhi, -1]`, `[0, ulo]` and `[hi, max_value]`. Additionally, while we only need to compute the union of 2 normal types or 2 dual types. Incorporating complementary would mean that we would need to compute the union of a non-complementary type and a complementary type, which is an entire different beast.

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

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


More information about the hotspot-compiler-dev mailing list