RFR: 8315066: Add unsigned bounds and known bits to TypeInt/Long [v47]
Quan Anh Mai
qamai at openjdk.org
Tue Apr 22 16:15:18 UTC 2025
On Tue, 22 Apr 2025 15:33:32 GMT, Emanuel Peter <epeter at openjdk.org> wrote:
>> Quan Anh Mai has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 61 commits:
>>
>> - Merge branch 'master' into unsignedbounds
>> - Merge branch 'master' into unsignedbounds
>> - reviews
>> - Merge branch 'master' into unsignedbounds
>> - refine comments
>> - Merge branch 'master' into unsignedbounds
>> - Merge branch 'master' into unsignedbounds
>> - harden SimpleCanonicalResult
>> - number lemmas
>> - include
>> - ... and 51 more: https://git.openjdk.org/jdk/compare/0995b940...cdab1911
>
> src/hotspot/share/opto/rangeinference.cpp line 263:
>
>> 261:
>> 262: // first_violation is the position of the violation counting from the
>> 263: // highest bit down (0-based), since i == 2, first_difference == 1
>
> Suggestion:
>
> // highest bit down (0-based). For example: i == 2, first_violation == 1.
>
> If that is not what you wanted, then I'm not sure what `first_difference` refers to ;)
Yes you are right, I have also changed the bit location to be more at the centre.
> src/hotspot/share/opto/rangeinference.cpp line 272:
>
>> 270: // that the result should not be smaller than this
>> 271: // 1 1 0 0 0 0 0 0
>> 272: U new_lo = (lo & -alignment) + alignment;
>
> Ouff, this is one of these one-liners that need some explanation... I'll try to decode it.
>
> Hmm, it is also not really the `new_lo` which we return, there is another operation below. Maybe we can give this intermediate result a descriptive name?
>
> It seems that already `-alignment` does something interesting... but I'll leave it to you to explain. I'm less familiar with all the bit tricks, and continually amazed what is possible :)
We want to obtain a value that is larger than `lo`, has the bit at a certain position set and all bits after that unset. It is aligning `lo` up to `alignment`. This is the standard operation for alignment when we know that `lo` is unaligned.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/17508#discussion_r2054430959
PR Review Comment: https://git.openjdk.org/jdk/pull/17508#discussion_r2054433118
More information about the hotspot-compiler-dev
mailing list