RFR: 8336245: AArch64: remove extra register copy when converting from long to pointer
Andrew Dinn
adinn at openjdk.org
Thu Jul 25 15:15:34 UTC 2024
On Thu, 25 Jul 2024 13:38:47 GMT, Andrew Haley <aph at openjdk.org> wrote:
>> Yes, I realise that this is 16 less than 65536. However, there are two things I don't follow.
>>
>> In the original code immLoffset was only used to define indOffLN i.e. a long offset used with a narrow pointer. The use of Address::offset_ok_for_immed(n->get_long(), 0) in the predicate limited narrow pointer offsets to -256 <= offset <= (2^12 - 1). With this change the top end of the range is now (2^12 - 1) << 4. I am wondering why that is appropriate?
>>
>> The change allows immLOffset to be used in the definition of indOffX2P. I am not clear why indOffX2P is not just defined using the existing operand immLoffset16 which has as its predicate Address::offset_ok_for_immed(n->get_long(), 4). The only difference I can see is that the alternative predicate used here will accept a positive offset that is not 16 byte aligned. Is that the intention of the redefinition? Again, why is that appropriate?
>
>> The change allows immLOffset to be used in the definition of indOffX2P. I am not clear why indOffX2P is not just defined using the existing operand immLoffset16 which has as its predicate Address::offset_ok_for_immed(n->get_long(), 4).
>
> After this change, `immLOffset` is a more general-purpose type than `immLoffset16`. `immLOffset` matches all possible address offsets, along with some impossible ones. For example, it matches all of the misaligned `Unsafe` accesses at any offset, regardless of operand size. In the (rare) event that an operand size and offset don't fit a single instruction, we'll split the instruction when we emit it.
>
> After this patch there will be a few rare cases where we have a regression in code size, but it's worth it for the simplicity and the size of the matcher logic, which would otherwise explode. I don't expect any significant regression in execution time.
>
> This patch is not the last word on the matter; later patches may well further reduce the number of integer offset types in a similar way. I don't think that many of the offsetL/I/X/P types do anything useful, and we'd probably profit from removing them, but that's another patch for anther day.
Ok, I see. The use of immLoffset as currently defined is actually correct for narrow oops and, indeed, for all other address base types. It allows for all possible offsets that might fit into a load an immediate slot. Whether we can legitimately encode the operand offset as an immediate or need instead to use an auxiliary add does not actually depend on the type of the address base but on the size of the datum fetched by the indirect load that consumes the operand. So, an indirect operand with offset 4098 would be too big to encode in an ldrb, fine to encode in an ldrh and invalid for encoding in an ldrw or ldrx because it is not suitably aligned.
That does imply we should get rid of the other (now redundant) immLoffset<n> operands. However, we can do that in a follow-up patch because it is not what this fix is addressing
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/20157#discussion_r1691636646
More information about the hotspot-dev
mailing list