Skip to content

Commit 0436907

Browse files
iainscatap
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 (cherry picked from commit bd796f1b0d4f8ff170ce51831916e9038dd8b1b9)
1 parent 5dc2ec9 commit 0436907

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
@@ -501,6 +501,7 @@ void aarch64_post_cfi_startproc (void);
501501
poly_int64 aarch64_initial_elimination_offset (unsigned, unsigned);
502502
int aarch64_get_condition_code (rtx);
503503
bool aarch64_address_valid_for_prefetch_p (rtx, bool);
504+
bool aarch64_address_valid_for_unscaled_prefetch_p (rtx, bool);
504505
bool aarch64_bitmask_imm (HOST_WIDE_INT val, machine_mode);
505506
unsigned HOST_WIDE_INT aarch64_and_split_imm1 (HOST_WIDE_INT val_in);
506507
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
@@ -9663,6 +9663,29 @@ aarch64_address_valid_for_prefetch_p (rtx x, bool strict_p)
96639663
return addr.type != ADDRESS_REG_WB;
96649664
}
96659665

9666+
/* Return true if the address X is valid for a PRFUM instruction.
9667+
STRICT_P is true if we should do strict checking with
9668+
aarch64_classify_address. */
9669+
9670+
bool
9671+
aarch64_address_valid_for_unscaled_prefetch_p (rtx x, bool strict_p)
9672+
{
9673+
struct aarch64_address_info addr;
9674+
9675+
/* PRFUM accepts the same addresses as DImode, but constrained to a range
9676+
-256..255. */
9677+
bool res = aarch64_classify_address (&addr, x, DImode, strict_p);
9678+
if (!res)
9679+
return false;
9680+
9681+
if (addr.offset && ((INTVAL (addr.offset) > 255)
9682+
|| (INTVAL (addr.offset) < -256)))
9683+
return false;
9684+
9685+
/* ... except writeback forms. */
9686+
return addr.type != ADDRESS_REG_WB;
9687+
}
9688+
96669689
bool
96679690
aarch64_symbolic_address_p (rtx x)
96689691
{

gcc/config/aarch64/aarch64.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,37 @@
828828
[(set_attr "type" "load_4")]
829829
)
830830

831+
(define_insn "prefetch_unscaled"
832+
[(prefetch (match_operand:DI 0 "aarch64_unscaled_prefetch_operand" "Du")
833+
(match_operand:QI 1 "const_int_operand" "")
834+
(match_operand:QI 2 "const_int_operand" ""))]
835+
""
836+
{
837+
const char * pftype[2][4] =
838+
{
839+
{"prfum\\tPLDL1STRM, %0",
840+
"prfum\\tPLDL3KEEP, %0",
841+
"prfum\\tPLDL2KEEP, %0",
842+
"prfum\\tPLDL1KEEP, %0"},
843+
{"prfum\\tPSTL1STRM, %0",
844+
"prfum\\tPSTL3KEEP, %0",
845+
"prfum\\tPSTL2KEEP, %0",
846+
"prfum\\tPSTL1KEEP, %0"},
847+
};
848+
849+
int locality = INTVAL (operands[2]);
850+
851+
gcc_assert (IN_RANGE (locality, 0, 3));
852+
853+
/* PRFUM accepts the same addresses as a 64-bit LDR so wrap
854+
the address into a DImode MEM so that aarch64_print_operand knows
855+
how to print it. */
856+
operands[0] = gen_rtx_MEM (DImode, operands[0]);
857+
return pftype[INTVAL(operands[1])][locality];
858+
}
859+
[(set_attr "type" "load_4")]
860+
)
861+
831862
(define_insn "trap"
832863
[(trap_if (const_int 1) (const_int 8))]
833864
""

gcc/config/aarch64/constraints.md

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

477+
(define_address_constraint "Du"
478+
"@internal
479+
An address valid for a prefetch instruction with an unscaled offset."
480+
(match_test "aarch64_address_valid_for_unscaled_prefetch_p (op, true)"))
481+
477482
(define_constraint "vgb"
478483
"@internal
479484
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
@@ -255,6 +255,9 @@
255255
(define_predicate "aarch64_prefetch_operand"
256256
(match_test "aarch64_address_valid_for_prefetch_p (op, false)"))
257257

258+
(define_predicate "aarch64_unscaled_prefetch_operand"
259+
(match_test "aarch64_address_valid_for_unscaled_prefetch_p (op, false)"))
260+
258261
(define_predicate "aarch64_valid_symref"
259262
(match_code "const, symbol_ref, label_ref")
260263
{

0 commit comments

Comments
 (0)