Skip to content

Commit 43ecba0

Browse files
iainsfxcoudert
authored andcommitted
aarch64, Darwin : Match conditions for a PRFUM insn.
This unpessimizes the prefetch cases for Darwin where the assembler is not able to substitute the prfum instructions automagically. This improves the fix for Issue gcc-mirror#43. * config/aarch64/aarch64-protos.h * config/aarch64/aarch64.c * config/aarch64/aarch64.md * config/aarch64/constraints.md * config/aarch64/predicates.md
1 parent f0fdc8e commit 43ecba0

File tree

5 files changed

+63
-0
lines changed

5 files changed

+63
-0
lines changed

gcc/config/aarch64/aarch64-protos.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,7 @@ void aarch64_post_cfi_startproc (void);
736736
poly_int64 aarch64_initial_elimination_offset (unsigned, unsigned);
737737
int aarch64_get_condition_code (rtx);
738738
bool aarch64_address_valid_for_prefetch_p (rtx, bool);
739+
bool aarch64_address_valid_for_unscaled_prefetch_p (rtx, bool);
739740
bool aarch64_bitmask_imm (HOST_WIDE_INT val, machine_mode);
740741
unsigned HOST_WIDE_INT aarch64_and_split_imm1 (HOST_WIDE_INT val_in);
741742
unsigned HOST_WIDE_INT aarch64_and_split_imm2 (HOST_WIDE_INT val_in);

gcc/config/aarch64/aarch64.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10083,6 +10083,29 @@ aarch64_address_valid_for_prefetch_p (rtx x, bool strict_p)
1008310083
return addr.type != ADDRESS_REG_WB;
1008410084
}
1008510085

10086+
/* Return true if the address X is valid for a PRFUM instruction.
10087+
STRICT_P is true if we should do strict checking with
10088+
aarch64_classify_address. */
10089+
10090+
bool
10091+
aarch64_address_valid_for_unscaled_prefetch_p (rtx x, bool strict_p)
10092+
{
10093+
struct aarch64_address_info addr;
10094+
10095+
/* PRFUM accepts the same addresses as DImode, but constrained to a range
10096+
-256..255. */
10097+
bool res = aarch64_classify_address (&addr, x, DImode, strict_p);
10098+
if (!res)
10099+
return false;
10100+
10101+
if (addr.offset && ((INTVAL (addr.offset) > 255)
10102+
|| (INTVAL (addr.offset) < -256)))
10103+
return false;
10104+
10105+
/* ... except writeback forms. */
10106+
return addr.type != ADDRESS_REG_WB;
10107+
}
10108+
1008610109
bool
1008710110
aarch64_symbolic_address_p (rtx x)
1008810111
{

gcc/config/aarch64/aarch64.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,37 @@
840840
[(set_attr "type" "load_4")]
841841
)
842842

843+
(define_insn "prefetch_unscaled"
844+
[(prefetch (match_operand:DI 0 "aarch64_unscaled_prefetch_operand" "Du")
845+
(match_operand:QI 1 "const_int_operand" "")
846+
(match_operand:QI 2 "const_int_operand" ""))]
847+
""
848+
{
849+
const char * pftype[2][4] =
850+
{
851+
{"prfum\\tPLDL1STRM, %0",
852+
"prfum\\tPLDL3KEEP, %0",
853+
"prfum\\tPLDL2KEEP, %0",
854+
"prfum\\tPLDL1KEEP, %0"},
855+
{"prfum\\tPSTL1STRM, %0",
856+
"prfum\\tPSTL3KEEP, %0",
857+
"prfum\\tPSTL2KEEP, %0",
858+
"prfum\\tPSTL1KEEP, %0"},
859+
};
860+
861+
int locality = INTVAL (operands[2]);
862+
863+
gcc_assert (IN_RANGE (locality, 0, 3));
864+
865+
/* PRFUM accepts the same addresses as a 64-bit LDR so wrap
866+
the address into a DImode MEM so that aarch64_print_operand knows
867+
how to print it. */
868+
operands[0] = gen_rtx_MEM (DImode, operands[0]);
869+
return pftype[INTVAL(operands[1])][locality];
870+
}
871+
[(set_attr "type" "load_4")]
872+
)
873+
843874
(define_insn "trap"
844875
[(trap_if (const_int 1) (const_int 8))]
845876
""

gcc/config/aarch64/constraints.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,11 @@
472472
An address valid for a prefetch instruction."
473473
(match_test "aarch64_address_valid_for_prefetch_p (op, true)"))
474474

475+
(define_address_constraint "Du"
476+
"@internal
477+
An address valid for a prefetch instruction with an unscaled offset."
478+
(match_test "aarch64_address_valid_for_unscaled_prefetch_p (op, true)"))
479+
475480
(define_constraint "vgb"
476481
"@internal
477482
A constraint that matches an immediate offset valid for SVE LD1B

gcc/config/aarch64/predicates.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,9 @@
257257
(define_predicate "aarch64_prefetch_operand"
258258
(match_test "aarch64_address_valid_for_prefetch_p (op, false)"))
259259

260+
(define_predicate "aarch64_unscaled_prefetch_operand"
261+
(match_test "aarch64_address_valid_for_unscaled_prefetch_p (op, false)"))
262+
260263
(define_predicate "aarch64_valid_symref"
261264
(match_code "const, symbol_ref, label_ref")
262265
{

0 commit comments

Comments
 (0)