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

Emanuel Peter epeter at openjdk.org
Thu May 1 08:42:01 UTC 2025


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

>> Quan Anh Mai has updated the pull request incrementally with two additional commits since the last revision:
>> 
>>  - wording
>>  - grammar, more details for non-existence
>
> src/hotspot/share/opto/rangeinference.cpp line 454:
> 
>> 452:   // it
>> 453:   U new_zeros = bits._zeros | (match_mask & ~bounds._lo);
>> 454:   U new_ones = bits._ones | (match_mask & bounds._lo);
> 
> Suggestion:
> 
>   U common_prefix = match_mask & bounds._lo;
>   assert(common_prefix == match_mask & bounds._lo, "common prefix of both");
>   U neg_common_prefix = match_mask & ~bounds._lo;
>   assert(neg_common_prefix == match_mask & ~bounds._lo, "common negated prefix of both");
>   U new_zeros = bits._zeros | neg_common_prefix;
>   U new_ones = bits._ones | common_prefix;
> 
> Just an idea. Up to you.

Hmm, I think your solution is understandable already, not sure mine is better. I'll still leave it for you here, feel free to mark it resolved.

> src/hotspot/share/opto/rangeinference.cpp line 509:
> 
>> 507:   // Trivially canonicalize the bounds so that srange._lo and urange._hi are
>> 508:   // both < 0 or >= 0. The same for srange._hi and urange._ulo. See TypeInt for
>> 509:   // detailed explanation.
> 
> You seem to suggest that `urange._hi` can be `< 0`. But it is unsigned, so that is confusing.
> This looks like Lemma 3 from TypeInt is relevant here, right? You might want to state that here,
> and still also bring this ASCII art up again here:
> 
>  *     Signed:
>  *     -----lo=========uhi---------0--------ulo==========hi-----
>  *     Unsigned:
>  *                                 0--------ulo==========hi----------lo=========uhi---------
> 
> Also, does `S(urange._lo) > S(urange._hi)` imply `U(srange._lo) > U(srange._hi)`?
> - If yes, assert it!
> - If no: are we missing an optimization?

It could also be that I'm missing some things here... So it could be good to refer to the exact things in `TypeInt` and the Lemma numbers you are using here. Otherwise it is a lot of work for the reader to check what you are doing here.

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

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


More information about the hotspot-compiler-dev mailing list