RFR: 8346836: C2: Verify CastII/CastLL bounds at runtime [v10]
Vladimir Ivanov
vlivanov at openjdk.org
Thu Apr 24 23:16:47 UTC 2025
On Thu, 24 Apr 2025 16:07:48 GMT, Quan Anh Mai <qamai at openjdk.org> wrote:
>> src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.cpp line 2763:
>>
>>> 2761:
>>> 2762: if (lo != min_jint && hi != max_jint) {
>>> 2763: subsw(rtmp, rval, lo);
>>
>> It turns out it's equivalent to `cmpw(rval, lo)` which is clearer IMO.
>
> I don't think it is, `cmpw(rval, lo)` is equivalent to `subsw(zr, rval, lo)`. However, if `lo` does not fit into an immediate instruction, `MacroAssembler::subsw`, which calls into `wrap_adds_subs_imm_insn`, will use `Rd` as a temporary register to store `lo`, this is invalid if `Rd` is `zr`. Am I understanding it right?
Yes, you are right. Completely forgot that there's only 12 bits available for the immediate (`Assembler::operand_valid_for_add_sub_immediate()`).
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/22880#discussion_r2059361881
More information about the hotspot-compiler-dev
mailing list