RFR: 8311847: Fix -Wconversion for assembler.hpp emit_int8,16 callers

Coleen Phillimore coleenp at openjdk.org
Tue Jul 11 12:32:12 UTC 2023


On Tue, 11 Jul 2023 02:34:14 GMT, Dean Long <dlong at openjdk.org> wrote:

>> src/hotspot/cpu/aarch64/assembler_aarch64.hpp line 265:
>> 
>>> 263:     int64_t chk = val >> (nbits - 1);
>>> 264:     guarantee (chk == -1 || chk == 0, "Field too big for insn");
>>> 265:     uint64_t uval = val;
>> 
>> Suggestion:
>> 
>>     int32_t val32 = checked_cast<int32_t>(val);
>>     unsigned uval = checked_cast<unsigned>(val32);
>
> uint64_t uval64 = val;
>     unsigned uval = checked_cast<unsigned>(uval64);
> This won't work for negative values, right?

val comes in signed, so we want to just chop off the sign.  checked_cast<unsigned>(signed val) will assert.  checked_cast<> doesn't do sign conversion.  We don't have a cast that does sign conversion.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/14822#discussion_r1259663449


More information about the hotspot-compiler-dev mailing list