1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple aarch64 -run-pass=aarch64-prelegalizer-combiner -verify-machineinstrs %s -o - | FileCheck %s
7 tracksRegLiveness: true
12 ; CHECK-LABEL: name: simplify_to_x
13 ; CHECK: liveins: $w0, $w1
15 ; CHECK-NEXT: %x:_(s32) = COPY $w0
16 ; CHECK-NEXT: $w0 = COPY %x(s32)
17 ; CHECK-NEXT: RET_ReallyLR implicit $w0
20 %add:_(s32) = G_ADD %x, %y
21 %sub:_(s32) = G_SUB %add, %y
23 RET_ReallyLR implicit $w0
27 tracksRegLiveness: true
32 ; CHECK-LABEL: name: simplify_to_y
33 ; CHECK: liveins: $w0, $w1
35 ; CHECK-NEXT: %y:_(s32) = COPY $w1
36 ; CHECK-NEXT: $w0 = COPY %y(s32)
37 ; CHECK-NEXT: RET_ReallyLR implicit $w0
40 %add:_(s32) = G_ADD %x, %y
41 %sub:_(s32) = G_SUB %add, %x
43 RET_ReallyLR implicit $w0
46 name: simplify_to_constant_x
47 tracksRegLiveness: true
52 ; CHECK-LABEL: name: simplify_to_constant_x
53 ; CHECK: liveins: $w0, $w1
55 ; CHECK-NEXT: %x:_(s32) = COPY $w0
56 ; CHECK-NEXT: $w0 = COPY %x(s32)
57 ; CHECK-NEXT: RET_ReallyLR implicit $w0
59 %y1:_(s32) = G_CONSTANT i32 1
60 %y2:_(s32) = G_CONSTANT i32 1
61 %add:_(s32) = G_ADD %x, %y1
62 %sub:_(s32) = G_SUB %add, %y2
64 RET_ReallyLR implicit $w0
67 name: simplify_to_constant_y
68 tracksRegLiveness: true
73 ; CHECK-LABEL: name: simplify_to_constant_y
74 ; CHECK: liveins: $w0, $w1
76 ; CHECK-NEXT: %y:_(s32) = COPY $w1
77 ; CHECK-NEXT: $w0 = COPY %y(s32)
78 ; CHECK-NEXT: RET_ReallyLR implicit $w0
79 %x1:_(s32) = G_CONSTANT i32 1
80 %x2:_(s32) = G_CONSTANT i32 1
82 %add:_(s32) = G_ADD %x1, %y
83 %sub:_(s32) = G_SUB %add, %x2
85 RET_ReallyLR implicit $w0
88 name: vector_simplify_to_x
89 tracksRegLiveness: true
94 ; CHECK-LABEL: name: vector_simplify_to_x
95 ; CHECK: liveins: $d0, $d1
97 ; CHECK-NEXT: %x:_(<2 x s32>) = COPY $d0
98 ; CHECK-NEXT: $d0 = COPY %x(<2 x s32>)
99 ; CHECK-NEXT: RET_ReallyLR implicit $d0
100 %x:_(<2 x s32>) = COPY $d0
101 %y:_(<2 x s32>) = COPY $d1
102 %add:_(<2 x s32>) = G_ADD %x, %y
103 %sub:_(<2 x s32>) = G_SUB %add, %y
104 $d0 = COPY %sub(<2 x s32>)
105 RET_ReallyLR implicit $d0
108 name: splat_simplify_to_x
109 tracksRegLiveness: true
114 ; CHECK-LABEL: name: splat_simplify_to_x
115 ; CHECK: liveins: $d0, $d1
117 ; CHECK-NEXT: %x:_(<2 x s32>) = COPY $d0
118 ; CHECK-NEXT: $d0 = COPY %x(<2 x s32>)
119 ; CHECK-NEXT: RET_ReallyLR implicit $d0
120 %x:_(<2 x s32>) = COPY $d0
121 %cst:_(s32) = G_CONSTANT i32 1
122 %y1:_(<2 x s32>) = G_BUILD_VECTOR %cst, %cst
123 %y2:_(<2 x s32>) = G_BUILD_VECTOR %cst, %cst
124 %add:_(<2 x s32>) = G_ADD %x, %y1
125 %sub:_(<2 x s32>) = G_SUB %add, %y2
126 $d0 = COPY %sub(<2 x s32>)
127 RET_ReallyLR implicit $d0
130 name: unique_registers_no_fold
131 tracksRegLiveness: true
134 liveins: $w0, $w1, $w2
135 ; CHECK-LABEL: name: unique_registers_no_fold
136 ; CHECK: liveins: $w0, $w1, $w2
138 ; CHECK-NEXT: %x:_(s32) = COPY $w0
139 ; CHECK-NEXT: %y:_(s32) = COPY $w1
140 ; CHECK-NEXT: %z:_(s32) = COPY $w2
141 ; CHECK-NEXT: %add:_(s32) = G_ADD %y, %x
142 ; CHECK-NEXT: %sub:_(s32) = G_SUB %add, %z
143 ; CHECK-NEXT: $w0 = COPY %sub(s32)
144 ; CHECK-NEXT: RET_ReallyLR implicit $w0
148 %add:_(s32) = G_ADD %y, %x
149 %sub:_(s32) = G_SUB %add, %z
151 RET_ReallyLR implicit $w0
154 name: unique_constants_no_fold
155 tracksRegLiveness: true
160 ; CHECK-LABEL: name: unique_constants_no_fold
161 ; CHECK: liveins: $w0, $w1
163 ; CHECK-NEXT: %x1:_(s32) = G_CONSTANT i32 1
164 ; CHECK-NEXT: %x2:_(s32) = G_CONSTANT i32 2
165 ; CHECK-NEXT: %y:_(s32) = COPY $w1
166 ; CHECK-NEXT: %add:_(s32) = G_ADD %y, %x1
167 ; CHECK-NEXT: %sub:_(s32) = G_SUB %add, %x2
168 ; CHECK-NEXT: $w0 = COPY %sub(s32)
169 ; CHECK-NEXT: RET_ReallyLR implicit $w0
170 %x1:_(s32) = G_CONSTANT i32 1
171 %x2:_(s32) = G_CONSTANT i32 2
173 %add:_(s32) = G_ADD %x1, %y
174 %sub:_(s32) = G_SUB %add, %x2
176 RET_ReallyLR implicit $w0
179 name: simplify_to_neg_y
180 tracksRegLiveness: true
184 ; x - (y + x) -> 0 - y
185 ; CHECK-LABEL: name: simplify_to_neg_y
186 ; CHECK: liveins: $w0, $w1
188 ; CHECK-NEXT: %y:_(s32) = COPY $w1
189 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
190 ; CHECK-NEXT: %sub:_(s32) = G_SUB [[C]], %y
191 ; CHECK-NEXT: $w0 = COPY %sub(s32)
192 ; CHECK-NEXT: RET_ReallyLR implicit $w0
195 %add:_(s32) = G_ADD %x, %y
196 %sub:_(s32) = G_SUB %x, %add
198 RET_ReallyLR implicit $w0
201 name: simplify_to_neg_x
202 tracksRegLiveness: true
206 ; y - (y + x) -> 0 - x
207 ; CHECK-LABEL: name: simplify_to_neg_x
208 ; CHECK: liveins: $w0, $w1
210 ; CHECK-NEXT: %x:_(s32) = COPY $w0
211 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
212 ; CHECK-NEXT: %sub:_(s32) = G_SUB [[C]], %x
213 ; CHECK-NEXT: $w0 = COPY %sub(s32)
214 ; CHECK-NEXT: RET_ReallyLR implicit $w0
217 %add:_(s32) = G_ADD %x, %y
218 %sub:_(s32) = G_SUB %y, %add
220 RET_ReallyLR implicit $w0
223 name: simplify_to_neg_y_constant
224 tracksRegLiveness: true
228 ; x - (y + x) -> 0 - y
229 ; CHECK-LABEL: name: simplify_to_neg_y_constant
230 ; CHECK: liveins: $w0, $w1
232 ; CHECK-NEXT: %y:_(s32) = COPY $w1
233 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
234 ; CHECK-NEXT: %sub:_(s32) = G_SUB [[C]], %y
235 ; CHECK-NEXT: $w0 = COPY %sub(s32)
236 ; CHECK-NEXT: RET_ReallyLR implicit $w0
237 %x1:_(s32) = G_CONSTANT i32 1
238 %x2:_(s32) = G_CONSTANT i32 1
240 %add:_(s32) = G_ADD %x1, %y
241 %sub:_(s32) = G_SUB %x2, %add
243 RET_ReallyLR implicit $w0
246 name: simplify_to_neg_x_constant
247 tracksRegLiveness: true
251 ; y - (y + x) -> 0 - x
252 ; CHECK-LABEL: name: simplify_to_neg_x_constant
253 ; CHECK: liveins: $w0, $w1
255 ; CHECK-NEXT: %x:_(s32) = COPY $w0
256 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
257 ; CHECK-NEXT: %sub:_(s32) = G_SUB [[C]], %x
258 ; CHECK-NEXT: $w0 = COPY %sub(s32)
259 ; CHECK-NEXT: RET_ReallyLR implicit $w0
261 %y1:_(s32) = G_CONSTANT i32 1
262 %y2:_(s32) = G_CONSTANT i32 1
263 %add:_(s32) = G_ADD %x, %y1
264 %sub:_(s32) = G_SUB %y2, %add
266 RET_ReallyLR implicit $w0
269 name: vector_simplify_to_neg_x
270 tracksRegLiveness: true
274 ; y - (y + x) -> 0 - x
275 ; CHECK-LABEL: name: vector_simplify_to_neg_x
276 ; CHECK: liveins: $d0, $d1
278 ; CHECK-NEXT: %x:_(<2 x s32>) = COPY $d0
279 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
280 ; CHECK-NEXT: [[BUILD_VECTOR:%[0-9]+]]:_(<2 x s32>) = G_BUILD_VECTOR [[C]](s32), [[C]](s32)
281 ; CHECK-NEXT: %sub:_(<2 x s32>) = G_SUB [[BUILD_VECTOR]], %x
282 ; CHECK-NEXT: $d0 = COPY %sub(<2 x s32>)
283 ; CHECK-NEXT: RET_ReallyLR implicit $d0
284 %x:_(<2 x s32>) = COPY $d0
285 %y:_(<2 x s32>) = COPY $d1
286 %add:_(<2 x s32>) = G_ADD %x, %y
287 %sub:_(<2 x s32>) = G_SUB %y, %add
288 $d0 = COPY %sub(<2 x s32>)
289 RET_ReallyLR implicit $d0
292 name: vector_simplify_to_neg_y_constant
293 tracksRegLiveness: true
297 ; x - (y + x) -> 0 - y
298 ; CHECK-LABEL: name: vector_simplify_to_neg_y_constant
299 ; CHECK: liveins: $d0, $d1
301 ; CHECK-NEXT: %y:_(<2 x s32>) = COPY $d1
302 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
303 ; CHECK-NEXT: [[BUILD_VECTOR:%[0-9]+]]:_(<2 x s32>) = G_BUILD_VECTOR [[C]](s32), [[C]](s32)
304 ; CHECK-NEXT: %sub:_(<2 x s32>) = G_SUB [[BUILD_VECTOR]], %y
305 ; CHECK-NEXT: $d0 = COPY %sub(<2 x s32>)
306 ; CHECK-NEXT: RET_ReallyLR implicit $d0
307 %cst:_(s32) = G_CONSTANT i32 1
308 %x1:_(<2 x s32>) = G_BUILD_VECTOR %cst, %cst
309 %x2:_(<2 x s32>) = G_BUILD_VECTOR %cst, %cst
310 %y:_(<2 x s32>) = COPY $d1
311 %add:_(<2 x s32>) = G_ADD %x1, %y
312 %sub:_(<2 x s32>) = G_SUB %x2, %add
313 $d0 = COPY %sub(<2 x s32>)
314 RET_ReallyLR implicit $d0
317 name: unique_registers_neg_no_fold
318 tracksRegLiveness: true
321 liveins: $w0, $w1, $w2
322 ; y - (y + x) -> 0 - x
323 ; CHECK-LABEL: name: unique_registers_neg_no_fold
324 ; CHECK: liveins: $w0, $w1, $w2
326 ; CHECK-NEXT: %x:_(s32) = COPY $w0
327 ; CHECK-NEXT: %y:_(s32) = COPY $w1
328 ; CHECK-NEXT: %z:_(s32) = COPY $w2
329 ; CHECK-NEXT: %add:_(s32) = G_ADD %x, %y
330 ; CHECK-NEXT: %sub:_(s32) = G_SUB %z, %add
331 ; CHECK-NEXT: $w0 = COPY %sub(s32)
332 ; CHECK-NEXT: RET_ReallyLR implicit $w0
336 %add:_(s32) = G_ADD %x, %y
337 %sub:_(s32) = G_SUB %z, %add
339 RET_ReallyLR implicit $w0
342 name: wrong_constant_neg_no_fold
343 tracksRegLiveness: true
347 ; x - (y + x) -> 0 - y
348 ; CHECK-LABEL: name: wrong_constant_neg_no_fold
349 ; CHECK: liveins: $w0, $w1
351 ; CHECK-NEXT: %x1:_(s32) = G_CONSTANT i32 1
352 ; CHECK-NEXT: %x2:_(s32) = G_CONSTANT i32 2
353 ; CHECK-NEXT: %y:_(s32) = COPY $w1
354 ; CHECK-NEXT: %add:_(s32) = G_ADD %y, %x1
355 ; CHECK-NEXT: %sub:_(s32) = G_SUB %x2, %add
356 ; CHECK-NEXT: $w0 = COPY %sub(s32)
357 ; CHECK-NEXT: RET_ReallyLR implicit $w0
358 %x1:_(s32) = G_CONSTANT i32 1
359 %x2:_(s32) = G_CONSTANT i32 2
361 %add:_(s32) = G_ADD %x1, %y
362 %sub:_(s32) = G_SUB %x2, %add
364 RET_ReallyLR implicit $w0