1 # RUN: llc -mtriple=aarch64-none-linux-gnu -run-pass aarch64-ldst-opt -verify-machineinstrs -o - %s | FileCheck %s
4 ### STG and its offset limits
6 # CHECK-LABEL: name: test_STG_post
7 # CHECK: STGPostIndex $x0, $x0, 7
14 $x0 = ADDXri $x0, 112, 0
15 RET_ReallyLR implicit $x0
18 # CHECK-LABEL: name: test_STG_post_same_reg
19 # CHECK: STGPostIndex $x1, $x0, 7
20 name: test_STG_post_same_reg
26 $x0 = ADDXri $x0, 112, 0
27 RET_ReallyLR implicit $x0
30 # CHECK-LABEL: name: test_STG_post_unaligned
31 # CHECK: STGOffset $x0, $x0, 0
32 # CHECK-NEXT: ADDXri $x0, 8, 0
33 name: test_STG_post_unaligned
39 $x0 = ADDXri $x0, 8, 0
40 RET_ReallyLR implicit $x0
43 # CHECK-LABEL: name: test_STG_post2
44 # CHECK: STGPostIndex $x0, $x0, -256
51 $x0 = SUBXri $x0, 4096, 0
52 RET_ReallyLR implicit $x0
55 # CHECK-LABEL: name: test_STG_post3
56 # CHECK: STGOffset $x0, $x0, 0
57 # CHECK-NEXT: SUBXri $x0, 4112, 0
64 $x0 = SUBXri $x0, 4112, 0
65 RET_ReallyLR implicit $x0
68 # CHECK-LABEL: name: test_STG_post4
69 # CHECK: STGPostIndex $x0, $x0, 255
76 $x0 = ADDXri $x0, 4080, 0
77 RET_ReallyLR implicit $x0
80 # CHECK-LABEL: name: test_STG_post5
81 # CHECK: STGOffset $x0, $x0, 0
82 # CHECK-NEXT: ADDXri $x0, 4096, 0
89 $x0 = ADDXri $x0, 4096, 0
90 RET_ReallyLR implicit $x0
93 ### The rest of ST*G variants.
95 # CHECK-LABEL: name: test_STZG_post
96 # CHECK: STZGPostIndex $x0, $x0, 7
102 STZGOffset $x0, $x0, 0
103 $x0 = ADDXri $x0, 112, 0
104 RET_ReallyLR implicit $x0
107 # CHECK-LABEL: name: test_ST2G_post
108 # CHECK: ST2GPostIndex $x0, $x0, 7
114 ST2GOffset $x0, $x0, 0
115 $x0 = ADDXri $x0, 112, 0
116 RET_ReallyLR implicit $x0
119 # CHECK-LABEL: name: test_STZ2G_post
120 # CHECK: STZ2GPostIndex $x0, $x0, 7
121 name: test_STZ2G_post
126 STZ2GOffset $x0, $x0, 0
127 $x0 = ADDXri $x0, 112, 0
128 RET_ReallyLR implicit $x0
131 ### STGP and its offset limits
133 # CHECK-LABEL: name: test_STGP_post
134 # CHECK: STGPpost $x1, $x2, $x0, 7
138 liveins: $x0, $x1, $x2
140 STGPi $x1, $x2, $x0, 0
141 $x0 = ADDXri $x0, 112, 0
142 RET_ReallyLR implicit $x0
145 # CHECK-LABEL: name: test_STGP_post2
146 # CHECK: STGPpost $x1, $x2, $x0, -64
147 name: test_STGP_post2
150 liveins: $x0, $x1, $x2
152 STGPi $x1, $x2, $x0, 0
153 $x0 = SUBXri $x0, 1024, 0
154 RET_ReallyLR implicit $x0
157 # CHECK-LABEL: name: test_STGP_post3
158 # CHECK: STGPi $x1, $x2, $x0, 0
159 # CHECK-NEXT: SUBXri $x0, 1040, 0
160 name: test_STGP_post3
163 liveins: $x0, $x1, $x2
165 STGPi $x1, $x2, $x0, 0
166 $x0 = SUBXri $x0, 1040, 0
167 RET_ReallyLR implicit $x0
170 # CHECK-LABEL: name: test_STGP_post4
171 # CHECK: STGPpost $x1, $x2, $x0, 63
172 name: test_STGP_post4
175 liveins: $x0, $x1, $x2
177 STGPi $x1, $x2, $x0, 0
178 $x0 = ADDXri $x0, 1008, 0
179 RET_ReallyLR implicit $x0
182 # CHECK-LABEL: name: test_STGP_post5
183 # CHECK: STGPi $x1, $x2, $x0, 0
184 # CHECK-NEXT: ADDXri $x0, 1024, 0
185 name: test_STGP_post5
188 liveins: $x0, $x1, $x2
190 STGPi $x1, $x2, $x0, 0
191 $x0 = ADDXri $x0, 1024, 0
192 RET_ReallyLR implicit $x0
195 ### Pre-indexed forms
197 # CHECK-LABEL: name: test_STG_pre
198 # CHECK: STGPreIndex $x0, $x0, 10
204 STGOffset $x0, $x0, 10
205 $x0 = ADDXri $x0, 160, 0
206 RET_ReallyLR implicit $x0
209 # CHECK-LABEL: name: test_STGP_pre
210 # CHECK: STGPpre $x1, $x2, $x0, 10
214 liveins: $x0, $x1, $x2
216 STGPi $x1, $x2, $x0, 10
217 $x0 = ADDXri $x0, 160, 0
218 RET_ReallyLR implicit $x0
221 ### Pre-indexed forms with add/sub coming before the store.
223 # CHECK-LABEL: name: test_STG_pre_back
224 # CHECK: STGPreIndex $x0, $x0, 2
225 name: test_STG_pre_back
230 $x0 = ADDXri $x0, 32, 0
231 STGOffset $x0, $x0, 0
232 RET_ReallyLR implicit $x0
235 # CHECK-LABEL: name: test_STGP_pre_back
236 # CHECK: STGPpre $x1, $x2, $x0, -3
237 name: test_STGP_pre_back
240 liveins: $x0, $x1, $x2
242 $x0 = SUBXri $x0, 48, 0
243 STGPi $x1, $x2, $x0, 0
244 RET_ReallyLR implicit $x0
247 ### STGP with source register == address register
249 # CHECK-LABEL: name: test_STGP_post_same_reg
250 # CHECK: STGPpost $x0, $x0, $x0, 7
251 name: test_STGP_post_same_reg
256 STGPi $x0, $x0, $x0, 0
257 $x0 = ADDXri $x0, 112, 0
258 RET_ReallyLR implicit $x0
261 # CHECK-LABEL: name: test_STGP_pre_same_reg
262 # CHECK: STGPpre $x0, $x0, $x0, 7
263 name: test_STGP_pre_same_reg
268 STGPi $x0, $x0, $x0, 7
269 $x0 = ADDXri $x0, 112, 0
270 RET_ReallyLR implicit $x0
273 # This case can not be merged because the source register is always read before writeback.
274 # CHECK-LABEL: name: test_STGP_pre_back_same_reg
275 # CHECK: SUBXri $x0, 48, 0
276 # CHECK-NEXT: STGPi $x0, $x0, $x0, 0
277 name: test_STGP_pre_back_same_reg
282 $x0 = SUBXri $x0, 48, 0
283 STGPi $x0, $x0, $x0, 0
284 RET_ReallyLR implicit $x0