Skip to content

Commit 60c9eab

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 b39ff5a commit 60c9eab

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

gcc/config/aarch64/aarch64.cc

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

11069-
/* Darwinpcs allows addresses on the stack that are not DImode aligned. */
11070-
if (TARGET_MACHO && addr.offset && (INTVAL (addr.offset) & 0x07))
11071-
return false;
11069+
/* For ELF targets using GAS, we emit prfm unconditionally; GAS will alter
11070+
the instruction to pick the prfum form where possible (i.e. when the
11071+
offset is in the range -256..255) and fall back to prfm otherwise.
11072+
We can reject cases where the offset exceeds the range usable by both
11073+
insns [-256..32760], or for offsets > 255 when the value is not divisible
11074+
by 8.
11075+
For Mach-O (Darwin) where the assembler uses the LLVM back end, that does
11076+
not yet do the substitution, so we must reject all prfum cases. */
11077+
if (addr.offset)
11078+
{
11079+
HOST_WIDE_INT offs = INTVAL (addr.offset);
11080+
if (offs < -256) /* Out of range for both prfum and prfm. */
11081+
return false;
11082+
if (offs > 32760) /* Out of range for prfm. */
11083+
return false;
11084+
if (offs & 0x07) /* We cannot use prfm. */
11085+
{
11086+
if (offs > 255) /* Out of range for prfum. */
11087+
return false;
11088+
if (TARGET_MACHO)
11089+
return false;
11090+
}
11091+
if (TARGET_MACHO && offs < 0)
11092+
return false;
11093+
}
1107211094

1107311095
/* ... except writeback forms. */
1107411096
return addr.type != ADDRESS_REG_WB;

0 commit comments

Comments
 (0)