1# RUN: llc -O0 -run-pass=aarch64-prelegalizer-combiner -global-isel -verify-machineinstrs %s -o - | FileCheck %s
2
3--- |
4  target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
5  target triple = "aarch64--"
6  define void @test_anyext(i8* %addr) {
7  entry:
8    ret void
9  }
10  define void @test_anyext_with_copy(i8* %addr) {
11  entry:
12    ret void
13  }
14  define void @test_signext(i8* %addr) {
15  entry:
16    ret void
17  }
18  define void @test_zeroext(i8* %addr) {
19  entry:
20    ret void
21  }
22  define void @test_2anyext(i8* %addr) {
23  entry:
24    ret void
25  }
26  define void @test_1anyext_1signext(i8* %addr) {
27  entry:
28    ret void
29  }
30  define void @test_1xor_1signext(i8* %addr) {
31  entry:
32    ret void
33  }
34  define void @test_1anyext_1zeroext(i8* %addr) {
35  entry:
36    ret void
37  }
38  define void @test_1signext_1zeroext(i8* %addr) {
39  entry:
40    ret void
41  }
42  define void @test_1anyext64_1signext32(i8* %addr) {
43  entry:
44    ret void
45  }
46  define void @test_1anyext32_1signext64(i8* %addr) {
47  entry:
48    ret void
49  }
50  define void @test_2anyext32_1signext64(i8* %addr) {
51  entry:
52    ret void
53  }
54  define void @test_multiblock_anyext(i8* %addr) {
55  entry:
56    ret void
57  }
58  define void @test_multiblock_signext(i8* %addr) {
59  entry:
60    ret void
61  }
62  define void @test_multiblock_zeroext(i8* %addr) {
63  entry:
64    ret void
65  }
66  define void @test_multiblock_2anyext(i8* %addr) {
67  entry:
68    ret void
69  }
70  define void @test_multiblock_1anyext64_1signext32(i8* %addr) {
71  entry:
72    ret void
73  }
74  define void @test_multiblock_1anyext32_1signext64(i8* %addr) {
75  entry:
76    ret void
77  }
78  define void @test_multiblock_2anyext32_1signext64(i8* %addr) {
79  entry:
80    ret void
81  }
82...
83
84---
85name:            test_anyext
86body: |
87  bb.0.entry:
88    liveins: $x0
89    ; CHECK-LABEL: name: test_anyext
90    ; CHECK: [[T0:%[0-9]+]]:_(p0) = COPY $x0
91    ; CHECK: [[T1:%[0-9]+]]:_(s32) = G_LOAD [[T0]](p0) :: (load 1 from %ir.addr)
92    ; CHECK: $w0 = COPY [[T1]](s32)
93    %0:_(p0) = COPY $x0
94    %1:_(s8) = G_LOAD %0 :: (load 1 from %ir.addr)
95    %2:_(s32) = G_ANYEXT %1
96    $w0 = COPY %2
97...
98
99---
100name:            test_anyext_with_copy
101body: |
102  bb.0.entry:
103    liveins: $x0
104    ; CHECK-LABEL: name: test_anyext
105    ; CHECK: [[T0:%[0-9]+]]:_(p0) = COPY $x0
106    ; CHECK: [[T1:%[0-9]+]]:_(s32) = G_LOAD [[T0]](p0) :: (load 1 from %ir.addr)
107    ; CHECK: $w0 = COPY [[T1]](s32)
108    %0:_(p0) = COPY $x0
109    %1:_(s8) = G_LOAD %0 :: (load 1 from %ir.addr)
110    %2:_(s8) = COPY %1
111    %3:_(s32) = G_ANYEXT %1
112    $w0 = COPY %3
113...
114
115---
116name:            test_signext
117body: |
118  bb.0.entry:
119    liveins: $x0
120    ; CHECK-LABEL: name: test_signext
121    ; CHECK: [[T0:%[0-9]+]]:_(p0) = COPY $x0
122    ; CHECK: [[T1:%[0-9]+]]:_(s32) = G_SEXTLOAD [[T0]](p0) :: (load 1 from %ir.addr)
123    ; CHECK: $w0 = COPY [[T1]](s32)
124    %0:_(p0) = COPY $x0
125    %1:_(s8) = G_LOAD %0 :: (load 1 from %ir.addr)
126    %2:_(s32) = G_SEXT %1
127    $w0 = COPY %2
128...
129
130---
131name:            test_zeroext
132body: |
133  bb.0.entry:
134    liveins: $x0
135    ; CHECK-LABEL: name: test_zeroext
136    ; CHECK: [[T0:%[0-9]+]]:_(p0) = COPY $x0
137    ; CHECK: [[T1:%[0-9]+]]:_(s32) = G_ZEXTLOAD [[T0]](p0) :: (load 1 from %ir.addr)
138    ; CHECK: $w0 = COPY [[T1]](s32)
139    %0:_(p0) = COPY $x0
140    %1:_(s8) = G_LOAD %0 :: (load 1 from %ir.addr)
141    %2:_(s32) = G_ZEXT %1
142    $w0 = COPY %2
143...
144
145---
146name:            test_2anyext
147body: |
148  bb.0.entry:
149    liveins: $x0
150    ; CHECK-LABEL: name: test_2anyext
151    ; CHECK: [[T0:%[0-9]+]]:_(p0) = COPY $x0
152    ; CHECK: [[T1:%[0-9]+]]:_(s32) = G_LOAD [[T0]](p0) :: (load 1 from %ir.addr)
153    ; CHECK: $w0 = COPY [[T1]](s32)
154    ; CHECK: $w1 = COPY [[T1]](s32)
155    %0:_(p0) = COPY $x0
156    %1:_(s8) = G_LOAD %0 :: (load 1 from %ir.addr)
157    %2:_(s32) = G_ANYEXT %1
158    %3:_(s32) = G_ANYEXT %1
159    $w0 = COPY %2
160    $w1 = COPY %3
161...
162
163---
164name:            test_1anyext_1signext
165body: |
166  bb.0.entry:
167    liveins: $x0
168    ; CHECK-LABEL: name: test_1anyext_1signext
169    ; CHECK: [[T0:%[0-9]+]]:_(p0) = COPY $x0
170    ; CHECK: [[T1:%[0-9]+]]:_(s32) = G_SEXTLOAD [[T0]](p0) :: (load 1 from %ir.addr)
171    ; CHECK: $w0 = COPY [[T1]](s32)
172    ; CHECK: $w1 = COPY [[T1]](s32)
173    %0:_(p0) = COPY $x0
174    %1:_(s8) = G_LOAD %0 :: (load 1 from %ir.addr)
175    %2:_(s32) = G_ANYEXT %1
176    %3:_(s32) = G_SEXT %1
177    $w0 = COPY %2
178    $w1 = COPY %3
179...
180
181---
182name:            test_1xor_1signext
183body: |
184  bb.0.entry:
185    liveins: $x0
186    ; CHECK-LABEL: name: test_1xor_1signext
187    ; CHECK: [[T0:%[0-9]+]]:_(p0) = COPY $x0
188    ; CHECK: [[T1:%[0-9]+]]:_(s32) = G_SEXTLOAD [[T0]](p0) :: (load 1 from %ir.addr)
189    ; CHECK: [[T2:%[0-9]+]]:_(s8) = G_TRUNC [[T1]]
190    ; CHECK: [[T3:%[0-9]+]]:_(s8) = G_XOR [[T2]], {{%[0-9]+}}
191    ; CHECK: [[T4:%[0-9]+]]:_(s32) = G_ANYEXT [[T3]]
192    ; CHECK: $w0 = COPY [[T4]](s32)
193    ; CHECK: $w1 = COPY [[T1]](s32)
194    %0:_(p0) = COPY $x0
195    %1:_(s8) = G_LOAD %0 :: (load 1 from %ir.addr)
196    %2:_(s8) = G_CONSTANT i8 -1
197    %3:_(s8) = G_XOR %1, %2
198    %5:_(s32) = G_ANYEXT %3
199    %6:_(s32) = G_SEXT %1
200    $w0 = COPY %5
201    $w1 = COPY %6
202...
203
204---
205name:            test_1anyext_1zeroext
206body: |
207  bb.0.entry:
208    liveins: $x0
209    ; CHECK-LABEL: name: test_1anyext_1zeroext
210    ; CHECK: [[T0:%[0-9]+]]:_(p0) = COPY $x0
211    ; CHECK: [[T1:%[0-9]+]]:_(s32) = G_ZEXTLOAD [[T0]](p0) :: (load 1 from %ir.addr)
212    ; CHECK: $w0 = COPY [[T1]](s32)
213    ; CHECK: $w1 = COPY [[T1]](s32)
214    %0:_(p0) = COPY $x0
215    %1:_(s8) = G_LOAD %0 :: (load 1 from %ir.addr)
216    %2:_(s32) = G_ANYEXT %1
217    %3:_(s32) = G_ZEXT %1
218    $w0 = COPY %2
219    $w1 = COPY %3
220...
221
222---
223name:            test_1signext_1zeroext
224body: |
225  bb.0.entry:
226    liveins: $x0
227    ; CHECK-LABEL: name: test_1signext_1zeroext
228    ; CHECK: [[T0:%[0-9]+]]:_(p0) = COPY $x0
229    ; CHECK: [[T1:%[0-9]+]]:_(s32) = G_SEXTLOAD [[T0]](p0) :: (load 1 from %ir.addr)
230    ; CHECK: [[T2:%[0-9]+]]:_(s8) = G_TRUNC [[T1]]
231    ; CHECK: [[T3:%[0-9]+]]:_(s32) = G_ZEXT [[T2]]
232    ; CHECK: $w0 = COPY [[T3]](s32)
233    ; CHECK: $w1 = COPY [[T1]](s32)
234    %0:_(p0) = COPY $x0
235    %1:_(s8) = G_LOAD %0 :: (load 1 from %ir.addr)
236    %2:_(s32) = G_ZEXT %1
237    %3:_(s32) = G_SEXT %1
238    $w0 = COPY %2
239    $w1 = COPY %3
240...
241
242---
243name:            test_1anyext64_1signext32
244body: |
245  bb.0.entry:
246    liveins: $x0
247    ; CHECK-LABEL: name: test_1anyext64_1signext32
248    ; CHECK: [[T0:%[0-9]+]]:_(p0) = COPY $x0
249    ; CHECK: [[T1:%[0-9]+]]:_(s32) = G_SEXTLOAD [[T0]](p0) :: (load 1 from %ir.addr)
250    ; CHECK-NOT: [[T1]]
251    ; CHECK: [[T2:%[0-9]+]]:_(s64) = G_ANYEXT [[T1]]
252    ; CHECK-NOT: [[T1]]
253    ; CHECK: $x0 = COPY [[T2]](s64)
254    ; CHECK: $w1 = COPY [[T1]](s32)
255    %0:_(p0) = COPY $x0
256    %1:_(s8) = G_LOAD %0 :: (load 1 from %ir.addr)
257    %2:_(s64) = G_ANYEXT %1
258    %3:_(s32) = G_SEXT %1
259    $x0 = COPY %2
260    $w1 = COPY %3
261...
262
263---
264name:            test_1anyext32_1signext64
265body: |
266  bb.0.entry:
267    liveins: $x0
268    ; CHECK-LABEL: name: test_1anyext32_1signext64
269    ; CHECK: [[T0:%[0-9]+]]:_(p0) = COPY $x0
270    ; CHECK: [[T1:%[0-9]+]]:_(s64) = G_SEXTLOAD [[T0]](p0) :: (load 1 from %ir.addr)
271    ; CHECK: [[T2:%[0-9]+]]:_(s8) = G_TRUNC [[T1]]
272    ; CHECK: [[T3:%[0-9]+]]:_(s32) = G_ANYEXT [[T2]]
273    ; CHECK: $w0 = COPY [[T3]](s32)
274    ; CHECK: $x1 = COPY [[T1]](s64)
275    %0:_(p0) = COPY $x0
276    %1:_(s8) = G_LOAD %0 :: (load 1 from %ir.addr)
277    %2:_(s32) = G_ANYEXT %1
278    %3:_(s64) = G_SEXT %1
279    $w0 = COPY %2
280    $x1 = COPY %3
281...
282
283---
284name:            test_2anyext32_1signext64
285body: |
286  bb.0.entry:
287    liveins: $x0
288    ; CHECK-LABEL: name: test_2anyext32_1signext64
289    ; CHECK: [[T0:%[0-9]+]]:_(p0) = COPY $x0
290    ; CHECK: [[T1:%[0-9]+]]:_(s64) = G_SEXTLOAD [[T0]](p0) :: (load 1 from %ir.addr)
291    ; CHECK: [[T2:%[0-9]+]]:_(s8) = G_TRUNC [[T1]]
292    ; CHECK: [[T3:%[0-9]+]]:_(s32) = G_ANYEXT [[T2]]
293    ; CHECK: [[T5:%[0-9]+]]:_(s32) = G_ANYEXT [[T2]]
294    ; CHECK: $w0 = COPY [[T3]](s32)
295    ; CHECK: $x1 = COPY [[T1]](s64)
296    ; CHECK: $w2 = COPY [[T5]](s32)
297    %0:_(p0) = COPY $x0
298    %1:_(s8) = G_LOAD %0 :: (load 1 from %ir.addr)
299    %2:_(s32) = G_ANYEXT %1
300    %3:_(s64) = G_SEXT %1
301    %4:_(s32) = G_ANYEXT %1
302    $w0 = COPY %2
303    $x1 = COPY %3
304    $w2 = COPY %4
305...
306
307---
308name:            test_multiblock_anyext
309body: |
310  bb.0.entry:
311    liveins: $x0
312    ; CHECK-LABEL: name: test_multiblock_anyext
313    ; CHECK: [[T0:%[0-9]+]]:_(p0) = COPY $x0
314    ; CHECK: [[T1:%[0-9]+]]:_(s32) = G_LOAD [[T0]](p0) :: (load 1 from %ir.addr)
315    ; CHECK: G_BR %bb.1
316    ; CHECK: $w0 = COPY [[T1]](s32)
317    %0:_(p0) = COPY $x0
318    %1:_(s8) = G_LOAD %0 :: (load 1 from %ir.addr)
319    G_BR %bb.1
320  bb.1:
321    %2:_(s32) = G_ANYEXT %1
322    $w0 = COPY %2
323...
324
325---
326name:            test_multiblock_signext
327body: |
328  bb.0.entry:
329    liveins: $x0
330    ; CHECK-LABEL: name: test_multiblock_signext
331    ; CHECK: [[T0:%[0-9]+]]:_(p0) = COPY $x0
332    ; CHECK: [[T1:%[0-9]+]]:_(s32) = G_SEXTLOAD [[T0]](p0) :: (load 1 from %ir.addr)
333    ; CHECK: $w0 = COPY [[T1]](s32)
334    %0:_(p0) = COPY $x0
335    %1:_(s8) = G_LOAD %0 :: (load 1 from %ir.addr)
336    G_BR %bb.1
337  bb.1:
338    %2:_(s32) = G_SEXT %1
339    $w0 = COPY %2
340...
341
342---
343name:            test_multiblock_zeroext
344body: |
345  bb.0.entry:
346    liveins: $x0
347    ; CHECK-LABEL: name: test_multiblock_zeroext
348    ; CHECK: [[T0:%[0-9]+]]:_(p0) = COPY $x0
349    ; CHECK: [[T1:%[0-9]+]]:_(s32) = G_ZEXTLOAD [[T0]](p0) :: (load 1 from %ir.addr)
350    ; CHECK: $w0 = COPY [[T1]](s32)
351    %0:_(p0) = COPY $x0
352    %1:_(s8) = G_LOAD %0 :: (load 1 from %ir.addr)
353    G_BR %bb.1
354  bb.1:
355    %2:_(s32) = G_ZEXT %1
356    $w0 = COPY %2
357...
358
359---
360name:            test_multiblock_2anyext
361body: |
362  bb.0.entry:
363    liveins: $x0
364    ; CHECK-LABEL: name: test_multiblock
365    ; CHECK: [[T0:%[0-9]+]]:_(p0) = COPY $x0
366    ; CHECK: [[T1:%[0-9]+]]:_(s32) = G_LOAD [[T0]](p0) :: (load 1 from %ir.addr)
367    ; CHECK: $w0 = COPY [[T1]](s32)
368    ; CHECK: $w1 = COPY [[T1]](s32)
369    %0:_(p0) = COPY $x0
370    %1:_(s8) = G_LOAD %0 :: (load 1 from %ir.addr)
371    %2:_(s32) = G_ANYEXT %1
372    G_BR %bb.1
373  bb.1:
374    %3:_(s32) = G_ANYEXT %1
375    $w0 = COPY %2
376    $w1 = COPY %3
377...
378
379---
380name:            test_multiblock_1anyext64_1signext32
381body: |
382  bb.0.entry:
383    liveins: $x0
384    ; CHECK-LABEL: name: test_multiblock_1anyext64_1signext32
385    ; CHECK: [[T0:%[0-9]+]]:_(p0) = COPY $x0
386    ; CHECK: [[T1:%[0-9]+]]:_(s32) = G_SEXTLOAD [[T0]](p0) :: (load 1 from %ir.addr)
387    ; CHECK: G_BR %bb.1
388    ; CHECK: [[T2:%[0-9]+]]:_(s64) = G_ANYEXT [[T1]]
389    ; CHECK: $x0 = COPY [[T2]](s64)
390    ; CHECK: $w1 = COPY [[T1]](s32)
391    %0:_(p0) = COPY $x0
392    %1:_(s8) = G_LOAD %0 :: (load 1 from %ir.addr)
393    G_BR %bb.1
394  bb.1:
395    %2:_(s64) = G_ANYEXT %1
396    %3:_(s32) = G_SEXT %1
397    $x0 = COPY %2
398    $w1 = COPY %3
399...
400
401---
402name:            test_multiblock_1anyext32_1signext64
403body: |
404  bb.0.entry:
405    liveins: $x0
406    ; CHECK-LABEL: name: test_multiblock_1anyext32_1signext64
407    ; CHECK: [[T0:%[0-9]+]]:_(p0) = COPY $x0
408    ; CHECK: [[T1:%[0-9]+]]:_(s64) = G_SEXTLOAD [[T0]](p0) :: (load 1 from %ir.addr)
409    ; CHECK: G_BR %bb.1
410    ; CHECK: [[T2:%[0-9]+]]:_(s8) = G_TRUNC [[T1]]
411    ; CHECK: [[T3:%[0-9]+]]:_(s32) = G_ANYEXT [[T2]]
412    ; CHECK: $w0 = COPY [[T3]](s32)
413    ; CHECK: $x1 = COPY [[T1]](s64)
414    %0:_(p0) = COPY $x0
415    %1:_(s8) = G_LOAD %0 :: (load 1 from %ir.addr)
416    G_BR %bb.1
417  bb.1:
418    %2:_(s32) = G_ANYEXT %1
419    %3:_(s64) = G_SEXT %1
420    $w0 = COPY %2
421    $x1 = COPY %3
422...
423
424---
425name:            test_multiblock_2anyext32_1signext64
426body: |
427  bb.0.entry:
428    liveins: $x0
429    ; CHECK-LABEL: name: test_multiblock_2anyext32_1signext64
430    ; CHECK: [[T0:%[0-9]+]]:_(p0) = COPY $x0
431    ; CHECK: [[T1:%[0-9]+]]:_(s64) = G_SEXTLOAD [[T0]](p0) :: (load 1 from %ir.addr)
432    ; CHECK: [[T2:%[0-9]+]]:_(s8) = G_TRUNC [[T1]]
433    ; CHECK: [[T3:%[0-9]+]]:_(s32) = G_ANYEXT [[T2]]
434    ; CHECK: G_BR %bb.1
435    ; CHECK: [[T4:%[0-9]+]]:_(s8) = G_TRUNC [[T1]]
436    ; CHECK: [[T5:%[0-9]+]]:_(s32) = G_ANYEXT [[T4]]
437    ; CHECK: $w0 = COPY [[T5]](s32)
438    ; CHECK: $x1 = COPY [[T1]](s64)
439    ; CHECK: $w2 = COPY [[T3]](s32)
440    %0:_(p0) = COPY $x0
441    %1:_(s8) = G_LOAD %0 :: (load 1 from %ir.addr)
442    %4:_(s32) = G_ANYEXT %1
443    G_BR %bb.1
444  bb.1:
445    %2:_(s32) = G_ANYEXT %1
446    %3:_(s64) = G_SEXT %1
447    $w0 = COPY %2
448    $x1 = COPY %3
449    $w2 = COPY %4
450...
451
452