xref: /llvm-project/llvm/test/CodeGen/AArch64/GlobalISel/combine-integer.mir (revision 17f3e00911b860d535f41185e605c47babcc2039)
1# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2# RUN: llc -mtriple aarch64 -run-pass=aarch64-prelegalizer-combiner %s -o - | FileCheck %s
3
4
5---
6name:   ZeroMinusAPlusB
7body:             |
8  bb.0:
9    liveins: $w0, $w1
10
11    ; CHECK-LABEL: name: ZeroMinusAPlusB
12    ; CHECK: liveins: $w0, $w1
13    ; CHECK-NEXT: {{  $}}
14    ; CHECK-NEXT: %a:_(s32) = COPY $w0
15    ; CHECK-NEXT: %b:_(s32) = COPY $w0
16    ; CHECK-NEXT: %add:_(s32) = G_SUB %b, %a
17    ; CHECK-NEXT: $w0 = COPY %add(s32)
18    ; CHECK-NEXT: RET_ReallyLR implicit $w0
19    %x:_(s32) = COPY $w0
20    %a:_(s32) = COPY $w0
21    %b:_(s32) = COPY $w0
22    %zero:_(s32) = G_CONSTANT i32 0
23    %sub:_(s32) = G_SUB %zero, %a
24    %add:_(s32) = G_ADD %sub, %b
25    $w0 = COPY %add
26    RET_ReallyLR implicit $w0
27
28...
29---
30name:   ZeroMinusAPlusB_multi_use
31body:             |
32  bb.0:
33    liveins: $w0, $w1
34
35    ; CHECK-LABEL: name: ZeroMinusAPlusB_multi_use
36    ; CHECK: liveins: $w0, $w1
37    ; CHECK-NEXT: {{  $}}
38    ; CHECK-NEXT: %a:_(s32) = COPY $w0
39    ; CHECK-NEXT: %b:_(s32) = COPY $w0
40    ; CHECK-NEXT: %zero:_(s32) = G_CONSTANT i32 0
41    ; CHECK-NEXT: %sub:_(s32) = G_SUB %zero, %a
42    ; CHECK-NEXT: %add:_(s32) = G_SUB %b, %a
43    ; CHECK-NEXT: $w0 = COPY %add(s32)
44    ; CHECK-NEXT: $w0 = COPY %sub(s32)
45    ; CHECK-NEXT: RET_ReallyLR implicit $w0
46    %x:_(s32) = COPY $w0
47    %a:_(s32) = COPY $w0
48    %b:_(s32) = COPY $w0
49    %zero:_(s32) = G_CONSTANT i32 0
50    %sub:_(s32) = G_SUB %zero, %a
51    %add:_(s32) = G_ADD %sub, %b
52    $w0 = COPY %add
53    $w0 = COPY %sub
54    RET_ReallyLR implicit $w0
55
56...
57---
58name:   APlusZeroMiunusB
59body:             |
60  bb.0:
61    liveins: $w0, $w1
62
63    ; CHECK-LABEL: name: APlusZeroMiunusB
64    ; CHECK: liveins: $w0, $w1
65    ; CHECK-NEXT: {{  $}}
66    ; CHECK-NEXT: %a:_(s64) = COPY $x1
67    ; CHECK-NEXT: %b:_(s64) = COPY $x2
68    ; CHECK-NEXT: %add:_(s64) = G_SUB %a, %b
69    ; CHECK-NEXT: $x0 = COPY %add(s64)
70    ; CHECK-NEXT: RET_ReallyLR implicit $x0
71    %x:_(s64) = COPY $x0
72    %a:_(s64) = COPY $x1
73    %b:_(s64) = COPY $x2
74    %zero:_(s64) = G_CONSTANT i64 0
75    %sub:_(s64) = G_SUB %zero, %b
76    %add:_(s64) = G_ADD %a, %sub
77    $x0 = COPY %add
78    RET_ReallyLR implicit $x0
79
80...
81---
82name:   APlusBMinusB
83body:             |
84  bb.0:
85    liveins: $w0, $w1
86
87    ; CHECK-LABEL: name: APlusBMinusB
88    ; CHECK: liveins: $w0, $w1
89    ; CHECK-NEXT: {{  $}}
90    ; CHECK-NEXT: %b:_(s64) = COPY $x1
91    ; CHECK-NEXT: $x0 = COPY %b(s64)
92    ; CHECK-NEXT: RET_ReallyLR implicit $x0
93    %a:_(s64) = COPY $x0
94    %b:_(s64) = COPY $x1
95    %zero:_(s64) = G_CONSTANT i64 0
96    %sub:_(s64) = G_SUB %b, %a
97    %add:_(s64) = G_ADD %a, %sub
98    $x0 = COPY %add
99    RET_ReallyLR implicit $x0
100
101...
102---
103name:   BMinusAPlusA
104body:             |
105  bb.0:
106    liveins: $w0, $w1
107
108    ; CHECK-LABEL: name: BMinusAPlusA
109    ; CHECK: liveins: $w0, $w1
110    ; CHECK-NEXT: {{  $}}
111    ; CHECK-NEXT: %b:_(s64) = COPY $x1
112    ; CHECK-NEXT: $x0 = COPY %b(s64)
113    ; CHECK-NEXT: RET_ReallyLR implicit $x0
114    %a:_(s64) = COPY $x0
115    %b:_(s64) = COPY $x1
116    %zero:_(s64) = G_CONSTANT i64 0
117    %sub:_(s64) = G_SUB %b, %a
118    %add:_(s64) = G_ADD %sub, %a
119    $x0 = COPY %add
120    RET_ReallyLR implicit $x0
121
122...
123---
124name:   AMinusBPlusCMinusA
125body:             |
126  bb.0:
127    liveins: $w0, $w1
128
129    ; CHECK-LABEL: name: AMinusBPlusCMinusA
130    ; CHECK: liveins: $w0, $w1
131    ; CHECK-NEXT: {{  $}}
132    ; CHECK-NEXT: %b:_(s64) = COPY $x1
133    ; CHECK-NEXT: %c:_(s64) = COPY $x2
134    ; CHECK-NEXT: %add:_(s64) = G_SUB %c, %b
135    ; CHECK-NEXT: $x0 = COPY %add(s64)
136    ; CHECK-NEXT: RET_ReallyLR implicit $x0
137    %a:_(s64) = COPY $x0
138    %b:_(s64) = COPY $x1
139    %c:_(s64) = COPY $x2
140    %zero:_(s64) = G_CONSTANT i64 0
141    %sub2:_(s64) = G_SUB %c, %a
142    %sub1:_(s64) = G_SUB %a, %b
143    %add:_(s64) = G_ADD %sub1, %sub2
144    $x0 = COPY %add
145    RET_ReallyLR implicit $x0
146
147...
148---
149name:   AMinusBPlusBMinusC
150body:             |
151  bb.0:
152    liveins: $w0, $w1
153
154    ; CHECK-LABEL: name: AMinusBPlusBMinusC
155    ; CHECK: liveins: $w0, $w1
156    ; CHECK-NEXT: {{  $}}
157    ; CHECK-NEXT: %a:_(s64) = COPY $x0
158    ; CHECK-NEXT: %c:_(s64) = COPY $x2
159    ; CHECK-NEXT: %add:_(s64) = G_SUB %a, %c
160    ; CHECK-NEXT: $x0 = COPY %add(s64)
161    ; CHECK-NEXT: RET_ReallyLR implicit $x0
162    %a:_(s64) = COPY $x0
163    %b:_(s64) = COPY $x1
164    %c:_(s64) = COPY $x2
165    %zero:_(s64) = G_CONSTANT i64 0
166    %sub2:_(s64) = G_SUB %b, %c
167    %sub1:_(s64) = G_SUB %a, %b
168    %add:_(s64) = G_ADD %sub1, %sub2
169    $x0 = COPY %add
170    RET_ReallyLR implicit $x0
171
172
173...
174---
175name:   APlusBMinusAplusC
176body:             |
177  bb.0:
178    liveins: $w0, $w1
179
180    ; CHECK-LABEL: name: APlusBMinusAplusC
181    ; CHECK: liveins: $w0, $w1
182    ; CHECK-NEXT: {{  $}}
183    ; CHECK-NEXT: %b:_(s64) = COPY $x1
184    ; CHECK-NEXT: %c:_(s64) = COPY $x2
185    ; CHECK-NEXT: %add:_(s64) = G_SUB %b, %c
186    ; CHECK-NEXT: $x0 = COPY %add(s64)
187    ; CHECK-NEXT: RET_ReallyLR implicit $x0
188    %a:_(s64) = COPY $x0
189    %b:_(s64) = COPY $x1
190    %c:_(s64) = COPY $x2
191    %zero:_(s64) = G_CONSTANT i64 0
192    %add1:_(s64) = G_ADD %a, %c
193    %sub1:_(s64) = G_SUB %b, %add1
194    %add:_(s64) = G_ADD %a, %sub1
195    $x0 = COPY %add
196    RET_ReallyLR implicit $x0
197
198...
199---
200name:   APlusBMinusCPlusA
201body:             |
202  bb.0:
203    liveins: $w0, $w1
204
205    ; CHECK-LABEL: name: APlusBMinusCPlusA
206    ; CHECK: liveins: $w0, $w1
207    ; CHECK-NEXT: {{  $}}
208    ; CHECK-NEXT: %b:_(s64) = COPY $x1
209    ; CHECK-NEXT: %c:_(s64) = COPY $x2
210    ; CHECK-NEXT: %add:_(s64) = G_SUB %b, %c
211    ; CHECK-NEXT: $x0 = COPY %add(s64)
212    ; CHECK-NEXT: RET_ReallyLR implicit $x0
213    %a:_(s64) = COPY $x0
214    %b:_(s64) = COPY $x1
215    %c:_(s64) = COPY $x2
216    %zero:_(s64) = G_CONSTANT i64 0
217    %add1:_(s64) = G_ADD %c, %a
218    %sub1:_(s64) = G_SUB %b, %add1
219    %add:_(s64) = G_ADD %a, %sub1
220    $x0 = COPY %add
221    RET_ReallyLR implicit $x0
222
223...
224---
225name:   APlusBMinusCPlusA_BV
226body:             |
227  bb.0:
228    liveins: $w0, $w1
229
230    ; CHECK-LABEL: name: APlusBMinusCPlusA_BV
231    ; CHECK: liveins: $w0, $w1
232    ; CHECK-NEXT: {{  $}}
233    ; CHECK-NEXT: %a1:_(s64) = COPY $x0
234    ; CHECK-NEXT: %b1:_(s64) = COPY $x1
235    ; CHECK-NEXT: %c1:_(s64) = COPY $x2
236    ; CHECK-NEXT: %b:_(<2 x s64>) = G_BUILD_VECTOR %b1(s64), %ba:_(s64)
237    ; CHECK-NEXT: %c:_(<2 x s64>) = G_BUILD_VECTOR %a1(s64), %c1(s64)
238    ; CHECK-NEXT: %add:_(<2 x s64>) = G_SUB %b, %c
239    ; CHECK-NEXT: $q0 = COPY %add(<2 x s64>)
240    ; CHECK-NEXT: RET_ReallyLR implicit $x0
241    %a1:_(s64) = COPY $x0
242    %b1:_(s64) = COPY $x1
243    %c1:_(s64) = COPY $x2
244    %a:_(<2 x s64>) = G_BUILD_VECTOR %a1:_(s64), %b1:_(s64)
245    %b:_(<2 x s64>) = G_BUILD_VECTOR %b1:_(s64), %ba:_(s64)
246    %c:_(<2 x s64>) = G_BUILD_VECTOR %a1:_(s64), %c1:_(s64)
247    %zero:_(s64) = G_CONSTANT i64 0
248    %add1:_(<2 x s64>) = G_ADD %c, %a
249    %sub1:_(<2 x s64>) = G_SUB %b, %add1
250    %add:_(<2 x s64>) = G_ADD %a, %sub1
251    $q0 = COPY %add
252    RET_ReallyLR implicit $x0
253
254...
255---
256name:   APlusC1MinusC2
257body:             |
258  bb.0:
259    liveins: $w0, $w1
260
261    ; CHECK-LABEL: name: APlusC1MinusC2
262    ; CHECK: liveins: $w0, $w1
263    ; CHECK-NEXT: {{  $}}
264    ; CHECK-NEXT: %a:_(s64) = COPY $x0
265    ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 -2
266    ; CHECK-NEXT: %sub:_(s64) = G_ADD %a, [[C]]
267    ; CHECK-NEXT: $x0 = COPY %sub(s64)
268    ; CHECK-NEXT: RET_ReallyLR implicit $x0
269    %a:_(s64) = COPY $x0
270    %c1:_(s64) = G_CONSTANT i64 5
271    %c2:_(s64) = G_CONSTANT i64 7
272    %add:_(s64) = G_ADD %a, %c1
273    %sub:_(s64) = G_SUB %add, %c2
274    $x0 = COPY %sub
275    RET_ReallyLR implicit $x0
276
277...
278---
279name:   C2MinusAPlusC1
280body:             |
281  bb.0:
282    liveins: $w0, $w1
283
284    ; CHECK-LABEL: name: C2MinusAPlusC1
285    ; CHECK: liveins: $w0, $w1
286    ; CHECK-NEXT: {{  $}}
287    ; CHECK-NEXT: %a:_(s64) = COPY $x0
288    ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 5
289    ; CHECK-NEXT: %sub:_(s64) = G_SUB [[C]], %a
290    ; CHECK-NEXT: $x0 = COPY %sub(s64)
291    ; CHECK-NEXT: RET_ReallyLR implicit $x0
292    %a:_(s64) = COPY $x0
293    %c1:_(s64) = G_CONSTANT i64 4
294    %c2:_(s64) = G_CONSTANT i64 9
295    %add:_(s64) = G_ADD %a, %c1
296    %sub:_(s64) = G_SUB %c2, %add
297    $x0 = COPY %sub
298    RET_ReallyLR implicit $x0
299
300...
301---
302name:   AMinusC1MinusC2
303body:             |
304  bb.0:
305    liveins: $w0, $w1
306
307    ; CHECK-LABEL: name: AMinusC1MinusC2
308    ; CHECK: liveins: $w0, $w1
309    ; CHECK-NEXT: {{  $}}
310    ; CHECK-NEXT: %a:_(s64) = COPY $x0
311    ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 -71
312    ; CHECK-NEXT: %sub:_(s64) = G_ADD %a, [[C]]
313    ; CHECK-NEXT: $x0 = COPY %sub(s64)
314    ; CHECK-NEXT: RET_ReallyLR implicit $x0
315    %a:_(s64) = COPY $x0
316    %c1:_(s64) = G_CONSTANT i64 11
317    %c2:_(s64) = G_CONSTANT i64 60
318    %sub1:_(s64) = G_SUB %a, %c1
319    %sub:_(s64) = G_SUB %sub1, %c2
320    $x0 = COPY %sub
321    RET_ReallyLR implicit $x0
322
323...
324---
325name:   C1Minus2MinusC2
326body:             |
327  bb.0:
328    liveins: $w0, $w1
329
330    ; CHECK-LABEL: name: C1Minus2MinusC2
331    ; CHECK: liveins: $w0, $w1
332    ; CHECK-NEXT: {{  $}}
333    ; CHECK-NEXT: %a:_(s64) = COPY $x0
334    ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 -49
335    ; CHECK-NEXT: %sub:_(s64) = G_SUB [[C]], %a
336    ; CHECK-NEXT: $x0 = COPY %sub(s64)
337    ; CHECK-NEXT: RET_ReallyLR implicit $x0
338    %a:_(s64) = COPY $x0
339    %c1:_(s64) = G_CONSTANT i64 11
340    %c2:_(s64) = G_CONSTANT i64 60
341    %sub1:_(s64) = G_SUB %c1, %a
342    %sub:_(s64) = G_SUB %sub1, %c2
343    $x0 = COPY %sub
344    RET_ReallyLR implicit $x0
345
346
347...
348---
349name:   AMinusC2PlusC2
350body:             |
351  bb.0:
352    liveins: $w0, $w1
353
354    ; CHECK-LABEL: name: AMinusC2PlusC2
355    ; CHECK: liveins: $w0, $w1
356    ; CHECK-NEXT: {{  $}}
357    ; CHECK-NEXT: %a:_(s64) = COPY $x0
358    ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 43
359    ; CHECK-NEXT: %add:_(s64) = G_ADD %a, [[C]]
360    ; CHECK-NEXT: $x0 = COPY %add(s64)
361    ; CHECK-NEXT: RET_ReallyLR implicit $x0
362    %a:_(s64) = COPY $x0
363    %c1:_(s64) = G_CONSTANT i64 13
364    %c2:_(s64) = G_CONSTANT i64 56
365    %sub:_(s64) = G_SUB %a, %c1
366    %add:_(s64) = G_ADD %sub, %c2
367    $x0 = COPY %add
368    RET_ReallyLR implicit $x0
369
370