Skip to content

Commit ce7c881

Browse files
committed
[AArch64] Add mayStore to more store instructions
As in #121565 we need to mark all stores as mayStore, hasSideEffects is not enough to prevent moving loads past the instructions. And marking the instructions as mayStore is a sensible thing to do on its own.
1 parent 27bc6bd commit ce7c881

File tree

5 files changed

+25
-18
lines changed

5 files changed

+25
-18
lines changed

llvm/lib/Target/AArch64/AArch64InstrFormats.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5028,6 +5028,7 @@ class BaseStoreUnprivilegedLSUI<bits<2> sz, dag oops, dag iops, string asm>
50285028
let Inst{9-5} = Rn;
50295029
let Inst{4-0} = Rt;
50305030
let PostEncoderMethod = "fixLoadStoreExclusive<1,0>";
5031+
let mayStore = 1;
50315032
}
50325033

50335034
multiclass StoreUnprivilegedLSUI<bits<2> sz, RegisterClass regtype, string asm> {
@@ -12532,6 +12533,7 @@ class Store64BV<bits<3> opc, string asm_inst, list<dag> pat = []>
1253212533
(ins GPR64x8:$Rt, GPR64sp:$Rn), (outs GPR64:$Rs), pat> {
1253312534
bits<5> Rs;
1253412535
let Inst{20-16} = Rs;
12536+
let mayStore = 1;
1253512537
}
1253612538

1253712539
class MOPSMemoryCopyMoveBase<bit isMove, bits<2> opcode, bits<2> op1,

llvm/lib/Target/AArch64/AArch64InstrInfo.td

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2799,14 +2799,17 @@ def : Pat<(int_aarch64_ldg GPR64:$Rt, (am_indexeds9s128 GPR64sp:$Rn, simm9s16:$
27992799

28002800
def : InstAlias<"ldg $Rt, [$Rn]", (LDG GPR64:$Rt, GPR64sp:$Rn, 0), 1>;
28012801

2802+
let mayLoad = 1 in
28022803
def LDGM : MemTagVector<1, "ldgm", "\t$Rt, [$Rn]",
28032804
(outs GPR64:$Rt), (ins GPR64sp:$Rn)>;
2805+
let mayStore = 1 in {
28042806
def STGM : MemTagVector<0, "stgm", "\t$Rt, [$Rn]",
28052807
(outs), (ins GPR64:$Rt, GPR64sp:$Rn)>;
28062808
def STZGM : MemTagVector<0, "stzgm", "\t$Rt, [$Rn]",
28072809
(outs), (ins GPR64:$Rt, GPR64sp:$Rn)> {
28082810
let Inst{23} = 0;
28092811
}
2812+
} // mayStore = 1
28102813

28112814
defm STG : MemTagStore<0b00, "stg">;
28122815
defm STZG : MemTagStore<0b01, "stzg">;
@@ -10018,8 +10021,10 @@ foreach i = 0-7 in {
1001810021
}
1001910022

1002010023
let Predicates = [HasLS64] in {
10024+
let mayLoad = 1 in
1002110025
def LD64B: LoadStore64B<0b101, "ld64b", (ins GPR64sp:$Rn),
1002210026
(outs GPR64x8:$Rt)>;
10027+
let mayStore = 1 in
1002310028
def ST64B: LoadStore64B<0b001, "st64b", (ins GPR64x8:$Rt, GPR64sp:$Rn),
1002410029
(outs)>;
1002510030
def ST64BV: Store64BV<0b011, "st64bv">;

llvm/test/tools/llvm-mca/AArch64/Ampere/Ampere1B/mte-instructions.s

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -215,12 +215,12 @@ stzgm xzr, [x2]
215215
# CHECK-NEXT: 2 4 0.50 * U ldgm x0, [x1]
216216
# CHECK-NEXT: 2 4 0.50 * U ldgm x1, [sp]
217217
# CHECK-NEXT: 2 4 0.50 * U ldgm xzr, [x2]
218-
# CHECK-NEXT: 1 1 0.50 U stgm x0, [x1]
219-
# CHECK-NEXT: 1 1 0.50 U stgm x1, [sp]
220-
# CHECK-NEXT: 1 1 0.50 U stgm xzr, [x2]
221-
# CHECK-NEXT: 1 1 0.50 U stzgm x0, [x1]
222-
# CHECK-NEXT: 1 1 0.50 U stzgm x1, [sp]
223-
# CHECK-NEXT: 1 1 0.50 U stzgm xzr, [x2]
218+
# CHECK-NEXT: 1 1 0.50 * U stgm x0, [x1]
219+
# CHECK-NEXT: 1 1 0.50 * U stgm x1, [sp]
220+
# CHECK-NEXT: 1 1 0.50 * U stgm xzr, [x2]
221+
# CHECK-NEXT: 1 1 0.50 * U stzgm x0, [x1]
222+
# CHECK-NEXT: 1 1 0.50 * U stzgm x1, [sp]
223+
# CHECK-NEXT: 1 1 0.50 * U stzgm xzr, [x2]
224224

225225
# CHECK: Resources:
226226
# CHECK-NEXT: [0.0] - Ampere1BUnitA

llvm/test/tools/llvm-mca/AArch64/Neoverse/N2-mte-instructions.s

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -215,12 +215,12 @@ stzgm xzr, [x2]
215215
# CHECK-NEXT: 1 4 0.33 * U ldgm x0, [x1]
216216
# CHECK-NEXT: 1 4 0.33 * U ldgm x1, [sp]
217217
# CHECK-NEXT: 1 4 0.33 * U ldgm xzr, [x2]
218-
# CHECK-NEXT: 2 1 0.50 U stgm x0, [x1]
219-
# CHECK-NEXT: 2 1 0.50 U stgm x1, [sp]
220-
# CHECK-NEXT: 2 1 0.50 U stgm xzr, [x2]
221-
# CHECK-NEXT: 2 1 0.50 U stzgm x0, [x1]
222-
# CHECK-NEXT: 2 1 0.50 U stzgm x1, [sp]
223-
# CHECK-NEXT: 2 1 0.50 U stzgm xzr, [x2]
218+
# CHECK-NEXT: 2 1 0.50 * U stgm x0, [x1]
219+
# CHECK-NEXT: 2 1 0.50 * U stgm x1, [sp]
220+
# CHECK-NEXT: 2 1 0.50 * U stgm xzr, [x2]
221+
# CHECK-NEXT: 2 1 0.50 * U stzgm x0, [x1]
222+
# CHECK-NEXT: 2 1 0.50 * U stzgm x1, [sp]
223+
# CHECK-NEXT: 2 1 0.50 * U stzgm xzr, [x2]
224224

225225
# CHECK: Resources:
226226
# CHECK-NEXT: [0.0] - N2UnitB

llvm/test/tools/llvm-mca/AArch64/Neoverse/N3-mte-instructions.s

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -215,12 +215,12 @@ stzgm xzr, [x2]
215215
# CHECK-NEXT: 1 4 0.33 * U ldgm x0, [x1]
216216
# CHECK-NEXT: 1 4 0.33 * U ldgm x1, [sp]
217217
# CHECK-NEXT: 1 4 0.33 * U ldgm xzr, [x2]
218-
# CHECK-NEXT: 2 1 0.50 U stgm x0, [x1]
219-
# CHECK-NEXT: 2 1 0.50 U stgm x1, [sp]
220-
# CHECK-NEXT: 2 1 0.50 U stgm xzr, [x2]
221-
# CHECK-NEXT: 2 1 0.50 U stzgm x0, [x1]
222-
# CHECK-NEXT: 2 1 0.50 U stzgm x1, [sp]
223-
# CHECK-NEXT: 2 1 0.50 U stzgm xzr, [x2]
218+
# CHECK-NEXT: 2 1 0.50 * U stgm x0, [x1]
219+
# CHECK-NEXT: 2 1 0.50 * U stgm x1, [sp]
220+
# CHECK-NEXT: 2 1 0.50 * U stgm xzr, [x2]
221+
# CHECK-NEXT: 2 1 0.50 * U stzgm x0, [x1]
222+
# CHECK-NEXT: 2 1 0.50 * U stzgm x1, [sp]
223+
# CHECK-NEXT: 2 1 0.50 * U stzgm xzr, [x2]
224224

225225
# CHECK: Resources:
226226
# CHECK-NEXT: [0.0] - N3UnitB

0 commit comments

Comments
 (0)