RFR: 8300800: UB: Shift exponent 32 is too large for 32-bit type 'int' [v2]
Andrew Dinn
adinn at openjdk.org
Mon Aug 12 12:50:33 UTC 2024
On Mon, 12 Aug 2024 09:23:24 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:
>> Afshin Zafari has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Used UCONST64(0) instead of UL.
>
> src/hotspot/cpu/aarch64/immediate_aarch64.cpp line 298:
>
>> 296: uint64_t or_bits_sub = replicate(or_bit, 1, nbits);
>> 297: uint64_t and_bits_top = (and_bits_sub << nbits) | ones(nbits);
>> 298: uint64_t or_bits_top = (UCONST64(0) << nbits) | or_bits_sub;
>
> I focused on the UL suffix earlier, and didn't really think about what this is doing. Why are we shifting
> a zero value at all? This equivalent to `uint64_t or_bits_top = or_bits_sub;`.
I believe this question came up in an earlier thread and was answered by @theRealAph. The shift of zero is there to emphasise continuity of this case with other cases where a non-zero value is shifted i.e. it serves to emphasize/document the connection between this implementation and the algorithm that it embodies.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/20530#discussion_r1713703513
More information about the hotspot-compiler-dev
mailing list