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

Quan Anh Mai qamai at openjdk.org
Mon May 5 12:42:24 UTC 2025


On Mon, 5 May 2025 07:10:28 GMT, Emanuel Peter <epeter at openjdk.org> wrote:

>> The thing is that the other operations are so trivial that it would be counter-productive to test them, it is like testing `add(int x, int y) { return x + y; }` :) The operations I test here are the non-trivial ones, that is sign extension and comparison. I have added some sanity `static_assert` to catch off-by-one errors, though.
>
> Well, it could be relatively easy to get a `>>` or equal operator wrong, because of the higher bits.
> I tend to get these things wrong, and tests save me there. You are not me, so I leave it up to you ;)

For signed integers, they are tricky, that's why I have tests for comparisons, and `>>` is not implemented yet. For unsigned ones, though, we simply chop off the higher bits so it is much less of a concern. I have added some more tests for the cases the input integer is outside the range of the `intn_t<nbits>` so that the results need to be wrapped.

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

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


More information about the hotspot-compiler-dev mailing list