Skip to content

Commit 288037c

Browse files
iainscatap
authored andcommitted
aarch64, Darwin : Restrict offsets for prfm.
The current LLVM-based assemblers reject offsets that are not suitable for prfm as written in the local section. However, there is advice elsewhere that says that this category of instruction should attempt to use the 9bit unscaled version before falling back to the scaled one. In the short-term reject values that the assembler will not accept. This partially addresses Issue gcc-mirror#43 gcc/ * config/aarch64/aarch64.c (aarch64_address_valid_for_prefetch_p): Reject values incompatible with pfrum and out of range for pfrm. For Mach-O, reject values that require prfum. (cherry picked from commit 76e872ee44318cafbd24b58e23234889164b67fd)
1 parent 1e653ea commit 288037c

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

gcc/config/aarch64/aarch64.c

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9633,9 +9633,31 @@ aarch64_address_valid_for_prefetch_p (rtx x, bool strict_p)
96339633
if (!res)
96349634
return false;
96359635

9636-
/* Darwinpcs allows addresses on the stack that are not DImode aligned. */
9637-
if (TARGET_MACHO && addr.offset && (INTVAL (addr.offset) & 0x07))
9638-
return false;
9636+
/* For ELF targets using GAS, we emit prfm unconditionally; GAS will alter
9637+
the instruction to pick the prfum form where possible (i.e. when the
9638+
offset is in the range -256..255) and fall back to prfm otherwise.
9639+
We can reject cases where the offset exceeds the range usable by both
9640+
insns [-256..32760], or for offsets > 255 when the value is not divisible
9641+
by 8.
9642+
For Mach-O (Darwin) where the assembler uses the LLVM back end, that does
9643+
not yet do the substitution, so we must reject all prfum cases. */
9644+
if (addr.offset)
9645+
{
9646+
HOST_WIDE_INT offs = INTVAL (addr.offset);
9647+
if (offs < -256) /* Out of range for both prfum and prfm. */
9648+
return false;
9649+
if (offs > 32760) /* Out of range for prfm. */
9650+
return false;
9651+
if (offs & 0x07)
9652+
{
9653+
if (offs > 255) /* Out of range for prfum. */
9654+
return false;
9655+
if (TARGET_MACHO)
9656+
return false;
9657+
}
9658+
if (TARGET_MACHO && offs < 0)
9659+
return false;
9660+
}
96399661

96409662
/* ... except writeback forms. */
96419663
return addr.type != ADDRESS_REG_WB;

0 commit comments

Comments
 (0)