ldst-opt.mir
4.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# RUN: llc -mtriple=aarch64--linux-gnu -run-pass=aarch64-ldst-opt %s -verify-machineinstrs -o - | FileCheck %s
---
name: promote-load-from-store
tracksRegLiveness: true
body: |
bb.0:
liveins: $w1, $x0, $lr
STRWui killed $w1, $x0, 0 :: (store 4)
CFI_INSTRUCTION 0
CFI_INSTRUCTION 0
CFI_INSTRUCTION 0
CFI_INSTRUCTION 0
CFI_INSTRUCTION 0
CFI_INSTRUCTION 0
CFI_INSTRUCTION 0
CFI_INSTRUCTION 0
CFI_INSTRUCTION 0
CFI_INSTRUCTION 0
CFI_INSTRUCTION 0
CFI_INSTRUCTION 0
CFI_INSTRUCTION 0
CFI_INSTRUCTION 0
CFI_INSTRUCTION 0
CFI_INSTRUCTION 0
CFI_INSTRUCTION 0
CFI_INSTRUCTION 0
CFI_INSTRUCTION 0
CFI_INSTRUCTION 0
$w0 = LDRHHui killed $x0, 1 :: (load 2)
RET $lr, implicit $w0
...
# Don't count transient instructions towards search limits.
# CHECK-LABEL: name: promote-load-from-store
# CHECK: STRWui $w1
# CHECK: UBFMWri killed $w1
---
name: store-pair
tracksRegLiveness: true
body: |
bb.0:
liveins: $w1, $x0, $lr
STRWui $w1, $x0, 0 :: (store 4)
CFI_INSTRUCTION 0
CFI_INSTRUCTION 0
CFI_INSTRUCTION 0
CFI_INSTRUCTION 0
CFI_INSTRUCTION 0
CFI_INSTRUCTION 0
CFI_INSTRUCTION 0
CFI_INSTRUCTION 0
CFI_INSTRUCTION 0
CFI_INSTRUCTION 0
CFI_INSTRUCTION 0
CFI_INSTRUCTION 0
CFI_INSTRUCTION 0
CFI_INSTRUCTION 0
CFI_INSTRUCTION 0
CFI_INSTRUCTION 0
CFI_INSTRUCTION 0
CFI_INSTRUCTION 0
CFI_INSTRUCTION 0
CFI_INSTRUCTION 0
STRWui killed $w1, killed $x0, 1 :: (store 4)
RET $lr
...
# CHECK-LABEL: name: store-pair
# CHECK: STPWi
---
name: store-pair-clearkill0
tracksRegLiveness: true
body: |
bb.0:
liveins: $w1, $x0, $lr
STRWui $w1, $x0, 0 :: (store 4)
$w2 = COPY $w1
$x3 = COPY $x0
STRWui killed $w1, killed $x0, 1 :: (store 4)
RET $lr
...
# When merging a lower store with an upper one, we must clear kill flags on
# the lower store.
# CHECK-LABEL: store-pair-clearkill0
# CHECK-NOT: STPWi $w1, killed $w1, $x0, 0 :: (store 4)
# CHECK: STPWi $w1, $w1, $x0, 0 :: (store 4)
# CHECK: $w2 = COPY $w1
# CHECK: RET $lr
---
name: store-pair-clearkill1
tracksRegLiveness: true
body: |
bb.0:
liveins: $x0, $lr
$w1 = MOVi32imm 13
$w2 = MOVi32imm 7
STRWui $w1, $x0, 1 :: (store 4)
$w2 = COPY killed $w1
STRWui killed $w2, $x0, 0 :: (store 4)
$w1 = MOVi32imm 42
$w2 = MOVi32imm 7
STRWui $w1, $x0, 0 :: (store 4)
$w2 = COPY killed $w1
STRWui killed $w2, killed $x0, 1 :: (store 4)
RET $lr
...
# When merging an upper store with a lower one, kill flags along the way need
# to be removed; In this case the kill flag on $w1.
# CHECK-LABEL: store-pair-clearkill1
# CHECK: $w1 = MOVi32imm
# CHECK: $w2 = MOVi32imm
# CHECK-NOT: $w2 = COPY killed $w1
# CHECK: $w2 = COPY $w1
# CHECK: STPWi killed $w2, $w1, $x0, 0
# CHECK: $w1 = MOVi32imm
# CHECK: $w2 = MOVi32imm
# CHECK-NOT: $w2 = COPY killed $w1
# CHECK: $w2 = COPY $w1
# CHECK: STPWi $w1, killed $w2, killed $x0, 0
---
name: store-load-clearkill
tracksRegLiveness: true
body: |
bb.0:
liveins: $w1
STRWui $w1, $sp, 0 :: (store 4)
$wzr = COPY killed $w1 ; killing use of $w1
$w11 = LDRWui $sp, 0 :: (load 4)
HINT 0, implicit $w11 ; some use of $w11
...
# When replaceing the load of a store-load pair with a copy the kill flags
# along the way need to be cleared.
# CHECK-LABEL: name: store-load-clearkill
# CHECK: STRWui $w1, $sp, 0 :: (store 4)
# CHECK-NOT: COPY killed $w1
# CHECK: $wzr = COPY $w1
# CHECK: $w11 = ORRWrs $wzr, $w1, 0
# CHECK: HINT 0, implicit $w11
---
name: promote-load-from-store-undef
tracksRegLiveness: true
body: |
bb.0:
liveins: $x0, $x2, $lr
STRWui undef $w1, $x0, 0 :: (store 4)
$w0 = LDRBBui $x0, 1 :: (load 2)
STRHHui undef $w3, $x2, 0 :: (store 4)
$w1 = LDRBBui $x2, 0 :: (load 4)
RET $lr, implicit $w0
...
# CHECK-LABEL: name: promote-load-from-store-undef
# CHECK: STRWui undef $w1
# CHECK: UBFMWri undef $w1
# CHECK: STRHHui undef $w3
# CHECK: ANDWri undef $w3
---
name: promote-load-from-store-trivial-kills
tracksRegLiveness: true
body: |
bb.0:
liveins: $x0, $lr
STRXui $x0, $sp, 0 :: (store 8)
STRXui killed $x0, $sp, 2 :: (store 8)
$x0 = LDRXui $sp, 0 :: (load 8)
BL &bar, csr_aarch64_aapcs, implicit-def $lr, implicit $sp, implicit $x0, implicit-def $sp
RET $lr
...
# CHECK-LABEL: name: promote-load-from-store-trivial-kills
# CHECK: STRXui $x0, $sp, 0
# CHECK: STRXui $x0, $sp, 2
# CHECK-NOT: LDRXui
# CHECK-NOT: ORR
# CHECK: BL &bar, csr_aarch64_aapcs, implicit-def $lr, implicit $sp, implicit $x0, implicit-def $sp