1# NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2# RUN: llc -O0 -run-pass=legalizer %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_scalar_add_big() {
8  entry:
9    ret void
10  }
11  define void @test_scalar_add_big_nonpow2() {
12  entry:
13    ret void
14  }
15  define void @test_scalar_add_small() {
16  entry:
17    ret void
18  }
19  define void @test_vector_add() {
20  entry:
21    ret void
22  }
23  define void @test_vector_add_nonpow2() {
24  entry:
25    ret void
26  }
27...
28
29---
30name:            test_scalar_add_big
31body: |
32  bb.0.entry:
33    liveins: $x0, $x1, $x2, $x3
34
35    ; CHECK-LABEL: name: test_scalar_add_big
36    ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
37    ; CHECK: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1
38    ; CHECK: [[COPY2:%[0-9]+]]:_(s64) = COPY $x2
39    ; CHECK: [[COPY3:%[0-9]+]]:_(s64) = COPY $x3
40    ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
41    ; CHECK: [[TRUNC:%[0-9]+]]:_(s1) = G_TRUNC [[C]](s32)
42    ; CHECK: [[UADDE:%[0-9]+]]:_(s64), [[UADDE1:%[0-9]+]]:_(s1) = G_UADDE [[COPY]], [[COPY2]], [[TRUNC]]
43    ; CHECK: [[UADDE2:%[0-9]+]]:_(s64), [[UADDE3:%[0-9]+]]:_(s1) = G_UADDE [[COPY1]], [[COPY3]], [[UADDE1]]
44    ; CHECK: $x0 = COPY [[UADDE]](s64)
45    ; CHECK: $x1 = COPY [[UADDE2]](s64)
46    %0:_(s64) = COPY $x0
47    %1:_(s64) = COPY $x1
48    %2:_(s64) = COPY $x2
49    %3:_(s64) = COPY $x3
50    %4:_(s128) = G_MERGE_VALUES %0, %1
51    %5:_(s128) = G_MERGE_VALUES %2, %3
52    %6:_(s128) = G_ADD %4, %5
53    %7:_(s64), %8:_(s64) = G_UNMERGE_VALUES %6
54    $x0 = COPY %7
55    $x1 = COPY %8
56...
57
58---
59name:            test_scalar_add_big_nonpow2
60registers:
61  - { id: 0, class: _ }
62  - { id: 1, class: _ }
63  - { id: 2, class: _ }
64  - { id: 3, class: _ }
65  - { id: 4, class: _ }
66  - { id: 5, class: _ }
67  - { id: 6, class: _ }
68  - { id: 7, class: _ }
69  - { id: 8, class: _ }
70  - { id: 9, class: _ }
71body: |
72  bb.0.entry:
73    liveins: $x0, $x1, $x2, $x3
74    ; CHECK-LABEL: name: test_scalar_add_big_nonpow2
75    ; CHECK-NOT: G_MERGE_VALUES
76    ; CHECK-NOT: G_UNMERGE_VALUES
77    ; CHECK-DAG: [[CARRY0_32:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
78    ; CHECK-DAG: [[CARRY0:%[0-9]+]]:_(s1) = G_TRUNC [[CARRY0_32]]
79    ; CHECK: [[RES_LO:%[0-9]+]]:_(s64), [[CARRY1:%[0-9]+]]:_(s1) = G_UADDE %0, %1, [[CARRY0]]
80    ; CHECK: [[RES_MI:%[0-9]+]]:_(s64), [[CARRY2:%[0-9]+]]:_(s1) = G_UADDE %1, %2, [[CARRY1]]
81    ; CHECK: [[RES_HI:%[0-9]+]]:_(s64), {{%.*}}(s1) = G_UADDE %2, %3, [[CARRY2]]
82    ; CHECK-NOT: G_MERGE_VALUES
83    ; CHECK-NOT: G_UNMERGE_VALUES
84    ; CHECK: $x0 = COPY [[RES_LO]]
85    ; CHECK: $x1 = COPY [[RES_MI]]
86    ; CHECK: $x2 = COPY [[RES_HI]]
87
88    %0(s64) = COPY $x0
89    %1(s64) = COPY $x1
90    %2(s64) = COPY $x2
91    %3(s64) = COPY $x3
92    %4(s192) = G_MERGE_VALUES %0, %1, %2
93    %5(s192) = G_MERGE_VALUES %1, %2, %3
94    %6(s192) = G_ADD %4, %5
95    %7(s64), %8(s64), %9(s64) = G_UNMERGE_VALUES %6
96    $x0 = COPY %7
97    $x1 = COPY %8
98    $x2 = COPY %9
99...
100
101---
102name:            test_scalar_add_small
103body: |
104  bb.0.entry:
105    liveins: $x0, $x1, $x2, $x3
106
107    ; CHECK-LABEL: name: test_scalar_add_small
108    ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
109    ; CHECK: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1
110    ; CHECK: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64)
111    ; CHECK: [[TRUNC1:%[0-9]+]]:_(s32) = G_TRUNC [[COPY1]](s64)
112    ; CHECK: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[TRUNC]], [[TRUNC1]]
113    ; CHECK: [[ANYEXT:%[0-9]+]]:_(s64) = G_ANYEXT [[ADD]](s32)
114    ; CHECK: $x0 = COPY [[ANYEXT]](s64)
115    %0:_(s64) = COPY $x0
116    %1:_(s64) = COPY $x1
117    %2:_(s8) = G_TRUNC %0
118    %3:_(s8) = G_TRUNC %1
119    %4:_(s8) = G_ADD %2, %3
120    %5:_(s64) = G_ANYEXT %4
121    $x0 = COPY %5
122...
123
124---
125name:            test_vector_add
126body: |
127  bb.0.entry:
128    liveins: $q0, $q1, $q2, $q3
129
130    ; CHECK-LABEL: name: test_vector_add
131    ; CHECK: [[COPY:%[0-9]+]]:_(<2 x s64>) = COPY $q0
132    ; CHECK: [[COPY1:%[0-9]+]]:_(<2 x s64>) = COPY $q1
133    ; CHECK: [[COPY2:%[0-9]+]]:_(<2 x s64>) = COPY $q2
134    ; CHECK: [[COPY3:%[0-9]+]]:_(<2 x s64>) = COPY $q3
135    ; CHECK: [[ADD:%[0-9]+]]:_(<2 x s64>) = G_ADD [[COPY]], [[COPY2]]
136    ; CHECK: [[ADD1:%[0-9]+]]:_(<2 x s64>) = G_ADD [[COPY1]], [[COPY3]]
137    ; CHECK: $q0 = COPY [[ADD]](<2 x s64>)
138    ; CHECK: $q1 = COPY [[ADD1]](<2 x s64>)
139    %0:_(<2 x s64>) = COPY $q0
140    %1:_(<2 x s64>) = COPY $q1
141    %2:_(<2 x s64>) = COPY $q2
142    %3:_(<2 x s64>) = COPY $q3
143    %4:_(<4 x s64>) = G_MERGE_VALUES %0, %1
144    %5:_(<4 x s64>) = G_MERGE_VALUES %2, %3
145    %6:_(<4 x s64>) = G_ADD %4, %5
146    %7:_(<2 x s64>), %8:_(<2 x s64>) = G_UNMERGE_VALUES %6
147    $q0 = COPY %7
148    $q1 = COPY %8
149...
150---
151name:            test_vector_add_nonpow2
152registers:
153  - { id: 0, class: _ }
154  - { id: 1, class: _ }
155  - { id: 2, class: _ }
156  - { id: 3, class: _ }
157  - { id: 4, class: _ }
158  - { id: 5, class: _ }
159  - { id: 6, class: _ }
160  - { id: 7, class: _ }
161  - { id: 8, class: _ }
162  - { id: 9, class: _ }
163body: |
164  bb.0.entry:
165    liveins: $q0, $q1, $q2, $q3
166    ; CHECK-LABEL: name: test_vector_add_nonpow2
167    ; CHECK-NOT: G_EXTRACT
168    ; CHECK-NOT: G_SEQUENCE
169    ; CHECK: [[RES_LO:%[0-9]+]]:_(<2 x s64>) = G_ADD %0, %1
170    ; CHECK: [[RES_MI:%[0-9]+]]:_(<2 x s64>) = G_ADD %1, %2
171    ; CHECK: [[RES_HI:%[0-9]+]]:_(<2 x s64>) = G_ADD %2, %3
172    ; CHECK-NOT: G_EXTRACT
173    ; CHECK-NOT: G_SEQUENCE
174    ; CHECK: $q0 = COPY [[RES_LO]]
175    ; CHECK: $q1 = COPY [[RES_MI]]
176    ; CHECK: $q2 = COPY [[RES_HI]]
177
178    %0(<2 x s64>) = COPY $q0
179    %1(<2 x s64>) = COPY $q1
180    %2(<2 x s64>) = COPY $q2
181    %3(<2 x s64>) = COPY $q3
182    %4(<6 x s64>) = G_MERGE_VALUES %0, %1, %2
183    %5(<6 x s64>) = G_MERGE_VALUES %1, %2, %3
184    %6(<6 x s64>) = G_ADD %4, %5
185    %7(<2 x s64>), %8(<2 x s64>), %9(<2 x s64>) = G_UNMERGE_VALUES %6
186    $q0 = COPY %7
187    $q1 = COPY %8
188    $q2 = COPY %9
189...
190