1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -run-pass=aarch64-prelegalizer-combiner -verify-machineinstrs -mtriple aarch64-unknown-unknown --aarch64prelegalizercombiner-only-enable-rule="reassoc_ptradd" %s -o - | FileCheck %s
6 name: test1_noreassoc_legal_already_new_is_illegal
8 tracksRegLiveness: true
15 ; CHECK-LABEL: name: test1_noreassoc_legal_already_new_is_illegal
18 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
19 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 1600
20 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 6
21 ; CHECK-NEXT: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
22 ; CHECK-NEXT: [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD [[COPY]], [[C]](s64)
23 ; CHECK-NEXT: [[PTR_ADD1:%[0-9]+]]:_(p0) = G_PTR_ADD [[PTR_ADD]], [[C1]](s64)
24 ; CHECK-NEXT: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[PTR_ADD1]](p0) :: (load (s32))
25 ; CHECK-NEXT: G_STORE [[C2]](s32), [[PTR_ADD]](p0) :: (store (s32))
26 ; CHECK-NEXT: $w0 = COPY [[LOAD]](s32)
27 ; CHECK-NEXT: RET_ReallyLR implicit $w0
29 %2:_(s64) = G_CONSTANT i64 1600
30 %4:_(s64) = G_CONSTANT i64 6
31 %9:_(s32) = G_CONSTANT i32 0
32 %10:_(p0) = G_PTR_ADD %0, %2(s64)
33 %11:_(p0) = G_PTR_ADD %10, %4(s64)
34 %7:_(s32) = G_LOAD %11(p0) :: (load 4)
35 G_STORE %9(s32), %10(p0) :: (store 4) ; other use of %10
37 RET_ReallyLR implicit $w0
41 name: test2_reassoc_already_legal_new_also_legal
49 ; CHECK-LABEL: name: test2_reassoc_already_legal_new_also_legal
52 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
53 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 10
54 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
55 ; CHECK-NEXT: [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD [[COPY]], [[C]](s64)
56 ; CHECK-NEXT: [[C2:%[0-9]+]]:_(s64) = G_CONSTANT i64 16
57 ; CHECK-NEXT: [[PTR_ADD1:%[0-9]+]]:_(p0) = G_PTR_ADD [[COPY]], [[C2]](s64)
58 ; CHECK-NEXT: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[PTR_ADD1]](p0) :: (load (s32))
59 ; CHECK-NEXT: G_STORE [[C1]](s32), [[PTR_ADD]](p0) :: (store (s32))
60 ; CHECK-NEXT: $w0 = COPY [[LOAD]](s32)
61 ; CHECK-NEXT: RET_ReallyLR implicit $w0
63 %2:_(s64) = G_CONSTANT i64 10
64 %4:_(s64) = G_CONSTANT i64 6
65 %9:_(s32) = G_CONSTANT i32 0
66 %10:_(p0) = G_PTR_ADD %0, %2(s64)
67 %11:_(p0) = G_PTR_ADD %10, %4(s64)
68 %7:_(s32) = G_LOAD %11(p0) :: (load 4)
69 G_STORE %9(s32), %10(p0) :: (store 4) ; other use of %10
71 RET_ReallyLR implicit $w0
75 name: test3_noreassoc_only_oneuse
83 ; CHECK-LABEL: name: test3_noreassoc_only_oneuse
86 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
87 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 4783
88 ; CHECK-NEXT: [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD [[COPY]], [[C]](s64)
89 ; CHECK-NEXT: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[PTR_ADD]](p0) :: (load (s32))
90 ; CHECK-NEXT: $w0 = COPY [[LOAD]](s32)
91 ; CHECK-NEXT: RET_ReallyLR implicit $w0
93 %10:_(s64) = G_CONSTANT i64 4783
94 %9:_(p0) = G_PTR_ADD %0, %10(s64)
95 %7:_(s32) = G_LOAD %9(p0) :: (load 4)
97 RET_ReallyLR implicit $w0
101 name: test4_reassoc_existing_is_already_illegal
109 ; CHECK-LABEL: name: test4_reassoc_existing_is_already_illegal
110 ; CHECK: liveins: $x0
112 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
113 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 17
114 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
115 ; CHECK-NEXT: [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD [[COPY]], [[C]](s64)
116 ; CHECK-NEXT: [[C2:%[0-9]+]]:_(s64) = G_CONSTANT i64 4096
117 ; CHECK-NEXT: [[PTR_ADD1:%[0-9]+]]:_(p0) = G_PTR_ADD [[COPY]], [[C2]](s64)
118 ; CHECK-NEXT: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[PTR_ADD1]](p0) :: (load (s32))
119 ; CHECK-NEXT: G_STORE [[C1]](s32), [[PTR_ADD]](p0) :: (store (s32))
120 ; CHECK-NEXT: $w0 = COPY [[LOAD]](s32)
121 ; CHECK-NEXT: RET_ReallyLR implicit $w0
123 %2:_(s64) = G_CONSTANT i64 17
124 %4:_(s64) = G_CONSTANT i64 4079
125 %9:_(s32) = G_CONSTANT i32 0
126 %10:_(p0) = G_PTR_ADD %0, %2(s64)
127 %11:_(p0) = G_PTR_ADD %10, %4(s64)
128 %7:_(s32) = G_LOAD %11(p0) :: (load 4)
129 G_STORE %9(s32), %10(p0) :: (store 4) ; other use of %10
131 RET_ReallyLR implicit $w0
135 name: test5_add_on_rhs
144 ; CHECK-LABEL: name: test5_add_on_rhs
145 ; CHECK: liveins: $x0, $x1
147 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
148 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1
149 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 1
150 ; CHECK-NEXT: [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD [[COPY]], [[COPY1]](s64)
151 ; CHECK-NEXT: [[PTR_ADD1:%[0-9]+]]:_(p0) = G_PTR_ADD [[PTR_ADD]], [[C]](s64)
152 ; CHECK-NEXT: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[PTR_ADD1]](p0) :: (load (s8))
153 ; CHECK-NEXT: $w0 = COPY [[LOAD]](s32)
154 ; CHECK-NEXT: RET_ReallyLR implicit $w0
157 %2:_(s64) = G_CONSTANT i64 1
158 %3:_(s64) = G_ADD %1, %2
159 %4:_(p0) = G_PTR_ADD %0, %3(s64)
160 %7:_(s32) = G_LOAD %4(p0) :: (load 1)
162 RET_ReallyLR implicit $w0
166 name: walk_through_inttoptr
168 tracksRegLiveness: true
172 ; CHECK-LABEL: name: walk_through_inttoptr
173 ; CHECK: liveins: $x0
175 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
176 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 1600
177 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
178 ; CHECK-NEXT: [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD [[COPY]], [[C]](s64)
179 ; CHECK-NEXT: [[C2:%[0-9]+]]:_(s64) = G_CONSTANT i64 1606
180 ; CHECK-NEXT: [[PTR_ADD1:%[0-9]+]]:_(p0) = G_PTR_ADD [[COPY]], [[C2]](s64)
181 ; CHECK-NEXT: %ptr_to_int:_(s64) = G_PTRTOINT [[PTR_ADD1]](p0)
182 ; CHECK-NEXT: %int_to_ptr:_(p0) = G_INTTOPTR %ptr_to_int(s64)
183 ; CHECK-NEXT: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD %int_to_ptr(p0) :: (load (s32))
184 ; CHECK-NEXT: G_STORE [[C1]](s32), [[PTR_ADD]](p0) :: (store (s32))
185 ; CHECK-NEXT: G_STORE %ptr_to_int(s64), [[PTR_ADD]](p0) :: (store (s64))
186 ; CHECK-NEXT: $w0 = COPY [[LOAD]](s32)
187 ; CHECK-NEXT: RET_ReallyLR implicit $w0
189 %2:_(s64) = G_CONSTANT i64 1600
190 %4:_(s64) = G_CONSTANT i64 6
191 %9:_(s32) = G_CONSTANT i32 0
192 %10:_(p0) = G_PTR_ADD %0, %2(s64)
193 %11:_(p0) = G_PTR_ADD %10, %4(s64)
194 %ptr_to_int:_(s64) = G_PTRTOINT %11
195 %int_to_ptr:_(p0) = G_INTTOPTR %ptr_to_int
196 %7:_(s32) = G_LOAD %int_to_ptr(p0) :: (load 4)
197 G_STORE %9(s32), %10(p0) :: (store 4) ; other use of %10
198 G_STORE %ptr_to_int(s64), %10(p0) :: (store 8)
200 RET_ReallyLR implicit $w0
203 name: reassoc_cst_inner_lhs
205 tracksRegLiveness: true
213 liveins: $w0, $x1, $x2, $x3
215 ; CHECK-LABEL: name: reassoc_cst_inner_lhs
216 ; CHECK: liveins: $w0, $x1, $x2, $x3
218 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x2
219 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x3
220 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 40
221 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 2
222 ; CHECK-NEXT: [[SHL:%[0-9]+]]:_(s64) = G_SHL [[COPY1]], [[C1]](s64)
223 ; CHECK-NEXT: [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD [[COPY]], [[SHL]](s64)
224 ; CHECK-NEXT: [[PTR_ADD1:%[0-9]+]]:_(p0) = G_PTR_ADD [[PTR_ADD]], [[C]](s64)
225 ; CHECK-NEXT: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[PTR_ADD1]](p0) :: (load (s32))
226 ; CHECK-NEXT: $w0 = COPY [[LOAD]](s32)
227 ; CHECK-NEXT: RET_ReallyLR
231 %8:_(s64) = G_CONSTANT i64 40
232 %9:_(p0) = G_PTR_ADD %2, %8(s64)
233 %10:_(s64) = G_CONSTANT i64 2
234 %11:_(s64) = G_SHL %3, %10
235 %12:_(p0) = G_PTR_ADD %9, %11(s64)
236 %14:_(s32) = G_LOAD %12(p0) :: (load (s32))
242 name: reassoc_cst_inner_lhs_multiuse
244 tracksRegLiveness: true
252 liveins: $w0, $x1, $x2, $x3
254 ; CHECK-LABEL: name: reassoc_cst_inner_lhs_multiuse
255 ; CHECK: liveins: $w0, $x1, $x2, $x3
257 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x2
258 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x3
259 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 40
260 ; CHECK-NEXT: [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD [[COPY]], [[C]](s64)
261 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 2
262 ; CHECK-NEXT: [[SHL:%[0-9]+]]:_(s64) = G_SHL [[COPY1]], [[C1]](s64)
263 ; CHECK-NEXT: [[PTR_ADD1:%[0-9]+]]:_(p0) = G_PTR_ADD [[PTR_ADD]], [[SHL]](s64)
264 ; CHECK-NEXT: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[PTR_ADD1]](p0) :: (load (s32))
265 ; CHECK-NEXT: $w0 = COPY [[LOAD]](s32)
266 ; CHECK-NEXT: $x0 = COPY [[PTR_ADD]](p0)
267 ; CHECK-NEXT: RET_ReallyLR
271 %8:_(s64) = G_CONSTANT i64 40
272 %9:_(p0) = G_PTR_ADD %2, %8(s64)
273 %10:_(s64) = G_CONSTANT i64 2
274 %11:_(s64) = G_SHL %3, %10
275 %12:_(p0) = G_PTR_ADD %9, %11(s64)
276 %14:_(s32) = G_LOAD %12(p0) :: (load (s32))
283 name: reassoc_cst_inner_lhs_const_lhs
285 tracksRegLiveness: true
293 liveins: $w0, $x1, $x2, $x3
295 ; CHECK-LABEL: name: reassoc_cst_inner_lhs_const_lhs
296 ; CHECK: liveins: $w0, $x1, $x2, $x3
298 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x2
299 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x3
300 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 40
301 ; CHECK-NEXT: [[INTTOPTR:%[0-9]+]]:_(p0) = G_INTTOPTR [[C]](s64)
302 ; CHECK-NEXT: [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD [[INTTOPTR]], [[COPY]](s64)
303 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 2
304 ; CHECK-NEXT: [[SHL:%[0-9]+]]:_(s64) = G_SHL [[COPY1]], [[C1]](s64)
305 ; CHECK-NEXT: [[PTR_ADD1:%[0-9]+]]:_(p0) = G_PTR_ADD [[PTR_ADD]], [[SHL]](s64)
306 ; CHECK-NEXT: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[PTR_ADD1]](p0) :: (load (s32))
307 ; CHECK-NEXT: $w0 = COPY [[LOAD]](s32)
308 ; CHECK-NEXT: RET_ReallyLR
312 %8:_(s64) = G_CONSTANT i64 40
313 %9:_(p0) = G_INTTOPTR %8(s64)
314 %10:_(p0) = G_PTR_ADD %9, %2(s64)
315 %11:_(s64) = G_CONSTANT i64 2
316 %12:_(s64) = G_SHL %3, %11
317 %13:_(p0) = G_PTR_ADD %10, %12(s64)
318 %15:_(s32) = G_LOAD %13(p0) :: (load (s32))