1# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2# RUN: llc -O0 -run-pass=legalizer -global-isel-abort=1 %s -o - | FileCheck %s
3
4--- |
5  target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
6  target triple = "aarch64--"
7  define void @test_combines_2() { ret void }
8  define void @test_combines_3() { ret void }
9  define void @test_combines_4() { ret void }
10  define void @test_combines_5() { ret void }
11  define void @test_combines_6() { ret void }
12...
13
14---
15name:            test_combines_2
16body: |
17  bb.0:
18    liveins: $w0
19
20    ; Here the types don't match.
21    ; CHECK-LABEL: name: test_combines_2
22    ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
23    ; CHECK: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[COPY]]
24    ; CHECK: [[MV:%[0-9]+]]:_(s64) = G_MERGE_VALUES [[COPY]](s32), [[ADD]](s32)
25    ; CHECK: [[EXTRACT:%[0-9]+]]:_(s1) = G_EXTRACT [[MV]](s64), 0
26    ; CHECK: [[EXTRACT1:%[0-9]+]]:_(s64) = COPY [[MV]](s64)
27    %0:_(s32) = COPY $w0
28
29    %1:_(s32) = G_ADD %0, %0
30    %2:_(s64) = G_MERGE_VALUES %0, %1
31    %3:_(s1) = G_EXTRACT %2, 0
32    %5:_(s32) = G_ANYEXT %3
33    $w0 = COPY %5
34    %4:_(s64) = COPY %2
35    $x0 = COPY %4
36...
37
38---
39name:            test_combines_3
40body: |
41  bb.0:
42    liveins: $w0
43
44    ; CHECK-LABEL: name: test_combines_3
45    ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
46    ; CHECK: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[COPY]]
47    ; CHECK: [[ADD1:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[ADD]]
48    %0:_(s32) = COPY $w0
49
50    %1:_(s32) = G_ADD %0, %0
51    %2:_(s64) = G_MERGE_VALUES %0, %1
52    %3:_(s32), %4:_(s32) = G_UNMERGE_VALUES %2
53    %5:_(s32) = G_ADD %3, %4
54    $w0 = COPY %5
55...
56
57---
58name:            test_combines_4
59body: |
60  bb.0:
61    liveins: $x0
62
63    ; CHECK-LABEL: name: test_combines_4
64    ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
65    ; CHECK: [[COPY1:%[0-9]+]]:_(s64) = COPY [[COPY]](s64)
66    ; CHECK: [[ADD:%[0-9]+]]:_(s64) = G_ADD [[COPY1]], [[COPY1]]
67    %0:_(s64) = COPY $x0
68
69    %1:_(s128) = G_MERGE_VALUES %0, %0
70    %2:_(s64) = G_EXTRACT %1, 0
71    %3:_(s64) = G_ADD %2, %2
72    $x0 = COPY %3
73...
74
75---
76name:            test_combines_5
77body: |
78  bb.0:
79    liveins: $w0
80
81    ; CHECK-LABEL: name: test_combines_5
82    ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
83    ; CHECK: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[COPY]]
84    ; CHECK: [[ADD1:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[ADD]]
85    %0:_(s32) = COPY $w0
86
87    %1:_(s32) = G_ADD %0, %0
88    %2:_(s64) = G_MERGE_VALUES %0, %1
89    %6:_(s64) = COPY %2
90    %7:_(s64) = COPY %6
91    %8:_(s64) = COPY %7
92    %3:_(s32), %4:_(s32) = G_UNMERGE_VALUES %8
93    %5:_(s32) = G_ADD %3, %4
94    $w0 = COPY %5
95...
96
97---
98name:            test_combines_6
99body: |
100  bb.0:
101    liveins: $w0
102
103    ; CHECK-LABEL: name: test_combines_6
104    ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
105    ; CHECK: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[COPY]]
106    ; CHECK: [[MV:%[0-9]+]]:_(s64) = G_MERGE_VALUES [[COPY]](s32), [[ADD]](s32)
107    ; CHECK: [[COPY1:%[0-9]+]]:_(s64) = COPY [[MV]](s64)
108    ; CHECK: [[COPY2:%[0-9]+]]:_(s64) = COPY [[COPY1]](s64)
109    ; CHECK: [[ADD1:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[ADD]]
110    ; CHECK: $w0 = COPY [[ADD1]](s32)
111    ; CHECK: $x0 = COPY [[COPY2]](s64)
112    %0:_(s32) = COPY $w0
113
114    %1:_(s32) = G_ADD %0, %0
115    %2:_(s64) = G_MERGE_VALUES %0, %1
116    %6:_(s64) = COPY %2
117    %7:_(s64) = COPY %6
118    %8:_(s64) = COPY %7
119    %3:_(s32), %4:_(s32) = G_UNMERGE_VALUES %8
120    %5:_(s32) = G_ADD %3, %4
121    $w0 = COPY %5
122    $x0 = COPY %7
123...
124