Skip to content

Commit 38909e7

Browse files
iainsfxcoudert
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.
1 parent de5a112 commit 38909e7

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
@@ -10053,9 +10053,31 @@ aarch64_address_valid_for_prefetch_p (rtx x, bool strict_p)
1005310053
if (!res)
1005410054
return false;
1005510055

10056-
/* Darwinpcs allows addresses on the stack that are not DImode aligned. */
10057-
if (TARGET_MACHO && addr.offset && (INTVAL (addr.offset) & 0x07))
10058-
return false;
10056+
/* For ELF targets using GAS, we emit prfm unconditionally; GAS will alter
10057+
the instruction to pick the prfum form where possible (i.e. when the
10058+
offset is in the range -256..255) and fall back to prfm otherwise.
10059+
We can reject cases where the offset exceeds the range usable by both
10060+
insns [-256..32760], or for offsets > 255 when the value is not divisible
10061+
by 8.
10062+
For Mach-O (Darwin) where the assembler uses the LLVM back end, that does
10063+
not yet do the substitution, so we must reject all prfum cases. */
10064+
if (addr.offset)
10065+
{
10066+
HOST_WIDE_INT offs = INTVAL (addr.offset);
10067+
if (offs < -256) /* Out of range for both prfum and prfm. */
10068+
return false;
10069+
if (offs > 32760) /* Out of range for prfm. */
10070+
return false;
10071+
if (offs & 0x07) /* We cannot use prfm. */
10072+
{
10073+
if (offs > 255) /* Out of range for prfum. */
10074+
return false;
10075+
if (TARGET_MACHO)
10076+
return false;
10077+
}
10078+
if (TARGET_MACHO && offs < 0)
10079+
return false;
10080+
}
1005910081

1006010082
/* ... except writeback forms. */
1006110083
return addr.type != ADDRESS_REG_WB;

0 commit comments

Comments
 (0)