Skip to content

Commit 9c81131

Browse files
committed
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 5b78793 commit 9c81131

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
@@ -10192,9 +10192,31 @@ aarch64_address_valid_for_prefetch_p (rtx x, bool strict_p)
1019210192
if (!res)
1019310193
return false;
1019410194

10195-
/* Darwinpcs allows addresses on the stack that are not DImode aligned. */
10196-
if (TARGET_MACHO && addr.offset && (INTVAL (addr.offset) & 0x07))
10197-
return false;
10195+
/* For ELF targets using GAS, we emit prfm unconditionally; GAS will alter
10196+
the instruction to pick the prfum form where possible (i.e. when the
10197+
offset is in the range -256..255) and fall back to prfm otherwise.
10198+
We can reject cases where the offset exceeds the range usable by both
10199+
insns [-256..32760], or for offsets > 255 when the value is not divisible
10200+
by 8.
10201+
For Mach-O (Darwin) where the assembler uses the LLVM back end, that does
10202+
not yet do the substitution, so we must reject all prfum cases. */
10203+
if (addr.offset)
10204+
{
10205+
HOST_WIDE_INT offs = INTVAL (addr.offset);
10206+
if (offs < -256) /* Out of range for both prfum and prfm. */
10207+
return false;
10208+
if (offs > 32760) /* Out of range for prfm. */
10209+
return false;
10210+
if (offs & 0x07) /* We cannot use prfm. */
10211+
{
10212+
if (offs > 255) /* Out of range for prfum. */
10213+
return false;
10214+
if (TARGET_MACHO)
10215+
return false;
10216+
}
10217+
if (TARGET_MACHO && offs < 0)
10218+
return false;
10219+
}
1019810220

1019910221
/* ... except writeback forms. */
1020010222
return addr.type != ADDRESS_REG_WB;

0 commit comments

Comments
 (0)