1 # RUN: llc -mtriple=aarch64-none-linux-gnu -mattr=+mte -run-pass aarch64-ldst-opt -verify-machineinstrs -o - %s | FileCheck %s
2 # RUN: llc -debugify-and-strip-all-safe -mtriple=aarch64-none-linux-gnu -mattr=+mte -run-pass aarch64-ldst-opt -verify-machineinstrs -o - %s | FileCheck %s
5 ### STG and its offset limits
7 # CHECK-LABEL: name: test_STG_post
8 # CHECK: STGPostIndex $x0, $x0, 7
15 $x0 = ADDXri $x0, 112, 0
16 RET_ReallyLR implicit $x0
19 # CHECK-LABEL: name: test_STG_post_same_reg
20 # CHECK: STGPostIndex $x1, $x0, 7
21 name: test_STG_post_same_reg
27 $x0 = ADDXri $x0, 112, 0
28 RET_ReallyLR implicit $x0
31 # CHECK-LABEL: name: test_STG_post_unaligned
32 # CHECK: STGi $x0, $x0, 0
33 # CHECK-NEXT: ADDXri $x0, 8, 0
34 name: test_STG_post_unaligned
40 $x0 = ADDXri $x0, 8, 0
41 RET_ReallyLR implicit $x0
44 # CHECK-LABEL: name: test_STG_post2
45 # CHECK: STGPostIndex $x0, $x0, -256
52 $x0 = SUBXri $x0, 4096, 0
53 RET_ReallyLR implicit $x0
56 # CHECK-LABEL: name: test_STG_post3
57 # CHECK: STGi $x0, $x0, 0
58 # CHECK-NEXT: SUBXri $x0, 4112, 0
65 $x0 = SUBXri $x0, 4112, 0
66 RET_ReallyLR implicit $x0
69 # CHECK-LABEL: name: test_STG_post4
70 # CHECK: STGPostIndex $x0, $x0, 255
77 $x0 = ADDXri $x0, 4080, 0
78 RET_ReallyLR implicit $x0
81 # CHECK-LABEL: name: test_STG_post5
82 # CHECK: STGi $x0, $x0, 0
83 # CHECK-NEXT: ADDXri $x0, 4096, 0
90 $x0 = ADDXri $x0, 4096, 0
91 RET_ReallyLR implicit $x0
94 ### The rest of ST*G variants.
96 # CHECK-LABEL: name: test_STZG_post
97 # CHECK: STZGPostIndex $x0, $x0, 7
104 $x0 = ADDXri $x0, 112, 0
105 RET_ReallyLR implicit $x0
108 # CHECK-LABEL: name: test_ST2G_post
109 # CHECK: ST2GPostIndex $x0, $x0, 7
116 $x0 = ADDXri $x0, 112, 0
117 RET_ReallyLR implicit $x0
120 # CHECK-LABEL: name: test_STZ2G_post
121 # CHECK: STZ2GPostIndex $x0, $x0, 7
122 name: test_STZ2G_post
128 $x0 = ADDXri $x0, 112, 0
129 RET_ReallyLR implicit $x0
132 ### STGP and its offset limits
134 # CHECK-LABEL: name: test_STGP_post
135 # CHECK: STGPpost $x1, $x2, $x0, 7
139 liveins: $x0, $x1, $x2
141 STGPi $x1, $x2, $x0, 0
142 $x0 = ADDXri $x0, 112, 0
143 RET_ReallyLR implicit $x0
146 # CHECK-LABEL: name: test_STGP_post2
147 # CHECK: STGPpost $x1, $x2, $x0, -64
148 name: test_STGP_post2
151 liveins: $x0, $x1, $x2
153 STGPi $x1, $x2, $x0, 0
154 $x0 = SUBXri $x0, 1024, 0
155 RET_ReallyLR implicit $x0
158 # CHECK-LABEL: name: test_STGP_post3
159 # CHECK: STGPi $x1, $x2, $x0, 0
160 # CHECK-NEXT: SUBXri $x0, 1040, 0
161 name: test_STGP_post3
164 liveins: $x0, $x1, $x2
166 STGPi $x1, $x2, $x0, 0
167 $x0 = SUBXri $x0, 1040, 0
168 RET_ReallyLR implicit $x0
171 # CHECK-LABEL: name: test_STGP_post4
172 # CHECK: STGPpost $x1, $x2, $x0, 63
173 name: test_STGP_post4
176 liveins: $x0, $x1, $x2
178 STGPi $x1, $x2, $x0, 0
179 $x0 = ADDXri $x0, 1008, 0
180 RET_ReallyLR implicit $x0
183 # CHECK-LABEL: name: test_STGP_post5
184 # CHECK: STGPi $x1, $x2, $x0, 0
185 # CHECK-NEXT: ADDXri $x0, 1024, 0
186 name: test_STGP_post5
189 liveins: $x0, $x1, $x2
191 STGPi $x1, $x2, $x0, 0
192 $x0 = ADDXri $x0, 1024, 0
193 RET_ReallyLR implicit $x0
196 ### Pre-indexed forms
198 # CHECK-LABEL: name: test_STG_pre
199 # CHECK: STGPreIndex $x0, $x0, 10
206 $x0 = ADDXri $x0, 160, 0
207 RET_ReallyLR implicit $x0
210 # CHECK-LABEL: name: test_STGP_pre
211 # CHECK: STGPpre $x1, $x2, $x0, 10
215 liveins: $x0, $x1, $x2
217 STGPi $x1, $x2, $x0, 10
218 $x0 = ADDXri $x0, 160, 0
219 RET_ReallyLR implicit $x0
222 ### Pre-indexed forms with add/sub coming before the store.
224 # CHECK-LABEL: name: test_STG_pre_back
225 # CHECK: STGPreIndex $x0, $x0, 2
226 name: test_STG_pre_back
231 $x0 = ADDXri $x0, 32, 0
233 RET_ReallyLR implicit $x0
236 # CHECK-LABEL: name: test_STGP_pre_back
237 # CHECK: STGPpre $x1, $x2, $x0, -3
238 name: test_STGP_pre_back
241 liveins: $x0, $x1, $x2
243 $x0 = SUBXri $x0, 48, 0
244 STGPi $x1, $x2, $x0, 0
245 RET_ReallyLR implicit $x0
248 ### STGP with source register == address register
250 # CHECK-LABEL: name: test_STGP_post_same_reg
251 # CHECK: STGPpost $x0, $x0, $x0, 7
252 name: test_STGP_post_same_reg
257 STGPi $x0, $x0, $x0, 0
258 $x0 = ADDXri $x0, 112, 0
259 RET_ReallyLR implicit $x0
262 # CHECK-LABEL: name: test_STGP_pre_same_reg
263 # CHECK: STGPpre $x0, $x0, $x0, 7
264 name: test_STGP_pre_same_reg
269 STGPi $x0, $x0, $x0, 7
270 $x0 = ADDXri $x0, 112, 0
271 RET_ReallyLR implicit $x0
274 # This case can not be merged because the source register is always read before writeback.
275 # CHECK-LABEL: name: test_STGP_pre_back_same_reg
276 # CHECK: SUBXri $x0, 48, 0
277 # CHECK-NEXT: STGPi $x0, $x0, $x0, 0
278 name: test_STGP_pre_back_same_reg
283 $x0 = SUBXri $x0, 48, 0
284 STGPi $x0, $x0, $x0, 0
285 RET_ReallyLR implicit $x0