Skip to content

Commit 6cd546e

Browse files
committed
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 aab5dd3 commit 6cd546e

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
@@ -745,6 +745,7 @@ void aarch64_post_cfi_startproc (void);
745745
poly_int64 aarch64_initial_elimination_offset (unsigned, unsigned);
746746
int aarch64_get_condition_code (rtx);
747747
bool aarch64_address_valid_for_prefetch_p (rtx, bool);
748+
bool aarch64_address_valid_for_unscaled_prefetch_p (rtx, bool);
748749
bool aarch64_bitmask_imm (HOST_WIDE_INT val, machine_mode);
749750
unsigned HOST_WIDE_INT aarch64_and_split_imm1 (HOST_WIDE_INT val_in);
750751
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
@@ -10383,6 +10383,29 @@ aarch64_address_valid_for_prefetch_p (rtx x, bool strict_p)
1038310383
return addr.type != ADDRESS_REG_WB;
1038410384
}
1038510385

10386+
/* Return true if the address X is valid for a PRFUM instruction.
10387+
STRICT_P is true if we should do strict checking with
10388+
aarch64_classify_address. */
10389+
10390+
bool
10391+
aarch64_address_valid_for_unscaled_prefetch_p (rtx x, bool strict_p)
10392+
{
10393+
struct aarch64_address_info addr;
10394+
10395+
/* PRFUM accepts the same addresses as DImode, but constrained to a range
10396+
-256..255. */
10397+
bool res = aarch64_classify_address (&addr, x, DImode, strict_p);
10398+
if (!res)
10399+
return false;
10400+
10401+
if (addr.offset && ((INTVAL (addr.offset) > 255)
10402+
|| (INTVAL (addr.offset) < -256)))
10403+
return false;
10404+
10405+
/* ... except writeback forms. */
10406+
return addr.type != ADDRESS_REG_WB;
10407+
}
10408+
1038610409
bool
1038710410
aarch64_symbolic_address_p (rtx x)
1038810411
{

gcc/config/aarch64/aarch64.md

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

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

gcc/config/aarch64/constraints.md

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

495+
(define_address_constraint "Du"
496+
"@internal
497+
An address valid for a prefetch instruction with an unscaled offset."
498+
(match_test "aarch64_address_valid_for_unscaled_prefetch_p (op, true)"))
499+
495500
(define_constraint "vgb"
496501
"@internal
497502
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)