RFR: 8315066: Add unsigned bounds and known bits to TypeInt/Long [v47]
Quan Anh Mai
qamai at openjdk.org
Tue Apr 22 16:41:23 UTC 2025
On Tue, 22 Apr 2025 16:01:59 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 293:
>
>> 291: // different bit between the result and lo must be the 3rd bit. As a result,
>> 292: // the result must not be smaller than:
>> 293: // 1 0 1 0 0 0 0 0
>
> Oh, I'm starting to get an intuition here. I think we can make it a bit more "intuitive".
>
> We start at the "first violation". We would like to flip the bit from 1 to 0, but since we are only allowed to increase the number, we also need to flip the 5th bit. But that is already 1 too, so we need to go to the 4th. That one we cannot flip from 0 to 1, because it is forced to be a 0 by zeros. So the first bit we can flip is the 3rd.
>
> Maybe this formulation with "which is the highest bit we can flip" could be helpful for the intuition?
That's a better guidance for sure, I have modified this part.
> src/hotspot/share/opto/rangeinference.cpp line 307:
>
>> 305: // violation, which is the last set bit of tmp
>> 306: // 0 1 1 0 0 0 0 0
>> 307: U tmp = ~either & find_mask;
>
> Did I understand that right: `tmp` is the bits that we cannot flip? Or is it the ones we can flip? A better name would be appreciated :)
> Same for `either`. worst case you call it `lo_or_zeros`... but that's not great either.
>
> I'm not fully seeing through the logic here yet, so I struggle to make good suggestions.
We can say that `tmp` is all the bits we can flip, although I think that is too ambiguous, what does "can" mean here. It is better to think of it as all the bits that are not lower than `first_violation` and are 0 in both `lo` and `zeros`.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/17508#discussion_r2054469385
PR Review Comment: https://git.openjdk.org/jdk/pull/17508#discussion_r2054468470
More information about the hotspot-compiler-dev
mailing list