Skip to content

Commit 2e1e3e1

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) Signed-off-by: Kirill A. Korinsky <[email protected]>
1 parent 6b603e3 commit 2e1e3e1

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
@@ -9739,9 +9739,31 @@ aarch64_address_valid_for_prefetch_p (rtx x, bool strict_p)
97399739
if (!res)
97409740
return false;
97419741

9742-
/* Darwinpcs allows addresses on the stack that are not DImode aligned. */
9743-
if (TARGET_MACHO && addr.offset && (INTVAL (addr.offset) & 0x07))
9744-
return false;
9742+
/* For ELF targets using GAS, we emit prfm unconditionally; GAS will alter
9743+
the instruction to pick the prfum form where possible (i.e. when the
9744+
offset is in the range -256..255) and fall back to prfm otherwise.
9745+
We can reject cases where the offset exceeds the range usable by both
9746+
insns [-256..32760], or for offsets > 255 when the value is not divisible
9747+
by 8.
9748+
For Mach-O (Darwin) where the assembler uses the LLVM back end, that does
9749+
not yet do the substitution, so we must reject all prfum cases. */
9750+
if (addr.offset)
9751+
{
9752+
HOST_WIDE_INT offs = INTVAL (addr.offset);
9753+
if (offs < -256) /* Out of range for both prfum and prfm. */
9754+
return false;
9755+
if (offs > 32760) /* Out of range for prfm. */
9756+
return false;
9757+
if (offs & 0x07)
9758+
{
9759+
if (offs > 255) /* Out of range for prfum. */
9760+
return false;
9761+
if (TARGET_MACHO)
9762+
return false;
9763+
}
9764+
if (TARGET_MACHO && offs < 0)
9765+
return false;
9766+
}
97459767

97469768
/* ... except writeback forms. */
97479769
return addr.type != ADDRESS_REG_WB;

0 commit comments

Comments
 (0)