1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=aarch64-none-linux-gnu -mattr=+neon | FileCheck %s --check-prefix=CHECK
4 declare {<1 x i32>, <1 x i1>} @llvm.uadd.with.overflow.v1i32(<1 x i32>, <1 x i32>)
5 declare {<2 x i32>, <2 x i1>} @llvm.uadd.with.overflow.v2i32(<2 x i32>, <2 x i32>)
6 declare {<3 x i32>, <3 x i1>} @llvm.uadd.with.overflow.v3i32(<3 x i32>, <3 x i32>)
7 declare {<4 x i32>, <4 x i1>} @llvm.uadd.with.overflow.v4i32(<4 x i32>, <4 x i32>)
8 declare {<6 x i32>, <6 x i1>} @llvm.uadd.with.overflow.v6i32(<6 x i32>, <6 x i32>)
9 declare {<8 x i32>, <8 x i1>} @llvm.uadd.with.overflow.v8i32(<8 x i32>, <8 x i32>)
11 declare {<16 x i8>, <16 x i1>} @llvm.uadd.with.overflow.v16i8(<16 x i8>, <16 x i8>)
12 declare {<8 x i16>, <8 x i1>} @llvm.uadd.with.overflow.v8i16(<8 x i16>, <8 x i16>)
13 declare {<2 x i64>, <2 x i1>} @llvm.uadd.with.overflow.v2i64(<2 x i64>, <2 x i64>)
15 declare {<4 x i24>, <4 x i1>} @llvm.uadd.with.overflow.v4i24(<4 x i24>, <4 x i24>)
16 declare {<4 x i1>, <4 x i1>} @llvm.uadd.with.overflow.v4i1(<4 x i1>, <4 x i1>)
17 declare {<2 x i128>, <2 x i1>} @llvm.uadd.with.overflow.v2i128(<2 x i128>, <2 x i128>)
19 define <1 x i32> @uaddo_v1i32(<1 x i32> %a0, <1 x i32> %a1, <1 x i32>* %p2) nounwind {
20 ; CHECK-LABEL: uaddo_v1i32:
22 ; CHECK-NEXT: add v1.2s, v0.2s, v1.2s
23 ; CHECK-NEXT: cmhi v0.2s, v0.2s, v1.2s
24 ; CHECK-NEXT: str s1, [x0]
26 %t = call {<1 x i32>, <1 x i1>} @llvm.uadd.with.overflow.v1i32(<1 x i32> %a0, <1 x i32> %a1)
27 %val = extractvalue {<1 x i32>, <1 x i1>} %t, 0
28 %obit = extractvalue {<1 x i32>, <1 x i1>} %t, 1
29 %res = sext <1 x i1> %obit to <1 x i32>
30 store <1 x i32> %val, <1 x i32>* %p2
34 define <2 x i32> @uaddo_v2i32(<2 x i32> %a0, <2 x i32> %a1, <2 x i32>* %p2) nounwind {
35 ; CHECK-LABEL: uaddo_v2i32:
37 ; CHECK-NEXT: add v1.2s, v0.2s, v1.2s
38 ; CHECK-NEXT: cmhi v0.2s, v0.2s, v1.2s
39 ; CHECK-NEXT: str d1, [x0]
41 %t = call {<2 x i32>, <2 x i1>} @llvm.uadd.with.overflow.v2i32(<2 x i32> %a0, <2 x i32> %a1)
42 %val = extractvalue {<2 x i32>, <2 x i1>} %t, 0
43 %obit = extractvalue {<2 x i32>, <2 x i1>} %t, 1
44 %res = sext <2 x i1> %obit to <2 x i32>
45 store <2 x i32> %val, <2 x i32>* %p2
49 define <3 x i32> @uaddo_v3i32(<3 x i32> %a0, <3 x i32> %a1, <3 x i32>* %p2) nounwind {
50 ; CHECK-LABEL: uaddo_v3i32:
52 ; CHECK-NEXT: add v1.4s, v0.4s, v1.4s
53 ; CHECK-NEXT: cmhi v0.4s, v0.4s, v1.4s
54 ; CHECK-NEXT: xtn v0.4h, v0.4s
55 ; CHECK-NEXT: add x8, x0, #8 // =8
56 ; CHECK-NEXT: sshll v0.4s, v0.4h, #0
57 ; CHECK-NEXT: st1 { v1.s }[2], [x8]
58 ; CHECK-NEXT: str d1, [x0]
60 %t = call {<3 x i32>, <3 x i1>} @llvm.uadd.with.overflow.v3i32(<3 x i32> %a0, <3 x i32> %a1)
61 %val = extractvalue {<3 x i32>, <3 x i1>} %t, 0
62 %obit = extractvalue {<3 x i32>, <3 x i1>} %t, 1
63 %res = sext <3 x i1> %obit to <3 x i32>
64 store <3 x i32> %val, <3 x i32>* %p2
68 define <4 x i32> @uaddo_v4i32(<4 x i32> %a0, <4 x i32> %a1, <4 x i32>* %p2) nounwind {
69 ; CHECK-LABEL: uaddo_v4i32:
71 ; CHECK-NEXT: add v1.4s, v0.4s, v1.4s
72 ; CHECK-NEXT: cmhi v0.4s, v0.4s, v1.4s
73 ; CHECK-NEXT: xtn v0.4h, v0.4s
74 ; CHECK-NEXT: sshll v0.4s, v0.4h, #0
75 ; CHECK-NEXT: str q1, [x0]
77 %t = call {<4 x i32>, <4 x i1>} @llvm.uadd.with.overflow.v4i32(<4 x i32> %a0, <4 x i32> %a1)
78 %val = extractvalue {<4 x i32>, <4 x i1>} %t, 0
79 %obit = extractvalue {<4 x i32>, <4 x i1>} %t, 1
80 %res = sext <4 x i1> %obit to <4 x i32>
81 store <4 x i32> %val, <4 x i32>* %p2
85 define <6 x i32> @uaddo_v6i32(<6 x i32> %a0, <6 x i32> %a1, <6 x i32>* %p2) nounwind {
86 ; CHECK-LABEL: uaddo_v6i32:
88 ; CHECK-NEXT: fmov s0, w6
89 ; CHECK-NEXT: mov x8, sp
90 ; CHECK-NEXT: mov v0.s[1], w7
91 ; CHECK-NEXT: ldr s2, [sp, #16]
92 ; CHECK-NEXT: ld1 { v0.s }[2], [x8]
93 ; CHECK-NEXT: add x9, sp, #8 // =8
94 ; CHECK-NEXT: add x10, sp, #24 // =24
95 ; CHECK-NEXT: fmov s1, w0
96 ; CHECK-NEXT: ld1 { v2.s }[1], [x10]
97 ; CHECK-NEXT: ld1 { v0.s }[3], [x9]
98 ; CHECK-NEXT: mov v1.s[1], w1
99 ; CHECK-NEXT: fmov s3, w4
100 ; CHECK-NEXT: ldr x11, [sp, #32]
101 ; CHECK-NEXT: mov v1.s[2], w2
102 ; CHECK-NEXT: mov v3.s[1], w5
103 ; CHECK-NEXT: mov v1.s[3], w3
104 ; CHECK-NEXT: add v2.4s, v3.4s, v2.4s
105 ; CHECK-NEXT: add v0.4s, v1.4s, v0.4s
106 ; CHECK-NEXT: cmhi v3.4s, v3.4s, v2.4s
107 ; CHECK-NEXT: cmhi v1.4s, v1.4s, v0.4s
108 ; CHECK-NEXT: str d2, [x11, #16]
109 ; CHECK-NEXT: xtn v2.4h, v3.4s
110 ; CHECK-NEXT: xtn v1.4h, v1.4s
111 ; CHECK-NEXT: sshll v2.4s, v2.4h, #0
112 ; CHECK-NEXT: sshll v1.4s, v1.4h, #0
113 ; CHECK-NEXT: mov w5, v2.s[1]
114 ; CHECK-NEXT: mov w1, v1.s[1]
115 ; CHECK-NEXT: mov w2, v1.s[2]
116 ; CHECK-NEXT: mov w3, v1.s[3]
117 ; CHECK-NEXT: fmov w4, s2
118 ; CHECK-NEXT: fmov w0, s1
119 ; CHECK-NEXT: str q0, [x11]
121 %t = call {<6 x i32>, <6 x i1>} @llvm.uadd.with.overflow.v6i32(<6 x i32> %a0, <6 x i32> %a1)
122 %val = extractvalue {<6 x i32>, <6 x i1>} %t, 0
123 %obit = extractvalue {<6 x i32>, <6 x i1>} %t, 1
124 %res = sext <6 x i1> %obit to <6 x i32>
125 store <6 x i32> %val, <6 x i32>* %p2
129 define <8 x i32> @uaddo_v8i32(<8 x i32> %a0, <8 x i32> %a1, <8 x i32>* %p2) nounwind {
130 ; CHECK-LABEL: uaddo_v8i32:
132 ; CHECK-NEXT: add v3.4s, v1.4s, v3.4s
133 ; CHECK-NEXT: add v2.4s, v0.4s, v2.4s
134 ; CHECK-NEXT: cmhi v1.4s, v1.4s, v3.4s
135 ; CHECK-NEXT: cmhi v0.4s, v0.4s, v2.4s
136 ; CHECK-NEXT: xtn v1.4h, v1.4s
137 ; CHECK-NEXT: xtn v0.4h, v0.4s
138 ; CHECK-NEXT: sshll v0.4s, v0.4h, #0
139 ; CHECK-NEXT: sshll v1.4s, v1.4h, #0
140 ; CHECK-NEXT: stp q2, q3, [x0]
142 %t = call {<8 x i32>, <8 x i1>} @llvm.uadd.with.overflow.v8i32(<8 x i32> %a0, <8 x i32> %a1)
143 %val = extractvalue {<8 x i32>, <8 x i1>} %t, 0
144 %obit = extractvalue {<8 x i32>, <8 x i1>} %t, 1
145 %res = sext <8 x i1> %obit to <8 x i32>
146 store <8 x i32> %val, <8 x i32>* %p2
150 define <16 x i32> @uaddo_v16i8(<16 x i8> %a0, <16 x i8> %a1, <16 x i8>* %p2) nounwind {
151 ; CHECK-LABEL: uaddo_v16i8:
153 ; CHECK-NEXT: add v4.16b, v0.16b, v1.16b
154 ; CHECK-NEXT: cmhi v0.16b, v0.16b, v4.16b
155 ; CHECK-NEXT: zip1 v1.8b, v0.8b, v0.8b
156 ; CHECK-NEXT: zip2 v2.8b, v0.8b, v0.8b
157 ; CHECK-NEXT: ext v0.16b, v0.16b, v0.16b, #8
158 ; CHECK-NEXT: ushll v1.4s, v1.4h, #0
159 ; CHECK-NEXT: ushll v2.4s, v2.4h, #0
160 ; CHECK-NEXT: zip1 v3.8b, v0.8b, v0.8b
161 ; CHECK-NEXT: zip2 v0.8b, v0.8b, v0.8b
162 ; CHECK-NEXT: shl v1.4s, v1.4s, #31
163 ; CHECK-NEXT: shl v2.4s, v2.4s, #31
164 ; CHECK-NEXT: ushll v3.4s, v3.4h, #0
165 ; CHECK-NEXT: ushll v5.4s, v0.4h, #0
166 ; CHECK-NEXT: sshr v0.4s, v1.4s, #31
167 ; CHECK-NEXT: sshr v1.4s, v2.4s, #31
168 ; CHECK-NEXT: shl v2.4s, v3.4s, #31
169 ; CHECK-NEXT: shl v3.4s, v5.4s, #31
170 ; CHECK-NEXT: sshr v2.4s, v2.4s, #31
171 ; CHECK-NEXT: sshr v3.4s, v3.4s, #31
172 ; CHECK-NEXT: str q4, [x0]
174 %t = call {<16 x i8>, <16 x i1>} @llvm.uadd.with.overflow.v16i8(<16 x i8> %a0, <16 x i8> %a1)
175 %val = extractvalue {<16 x i8>, <16 x i1>} %t, 0
176 %obit = extractvalue {<16 x i8>, <16 x i1>} %t, 1
177 %res = sext <16 x i1> %obit to <16 x i32>
178 store <16 x i8> %val, <16 x i8>* %p2
182 define <8 x i32> @uaddo_v8i16(<8 x i16> %a0, <8 x i16> %a1, <8 x i16>* %p2) nounwind {
183 ; CHECK-LABEL: uaddo_v8i16:
185 ; CHECK-NEXT: add v2.8h, v0.8h, v1.8h
186 ; CHECK-NEXT: cmhi v0.8h, v0.8h, v2.8h
187 ; CHECK-NEXT: xtn v0.8b, v0.8h
188 ; CHECK-NEXT: zip1 v1.8b, v0.8b, v0.8b
189 ; CHECK-NEXT: zip2 v0.8b, v0.8b, v0.8b
190 ; CHECK-NEXT: ushll v1.4s, v1.4h, #0
191 ; CHECK-NEXT: ushll v0.4s, v0.4h, #0
192 ; CHECK-NEXT: shl v1.4s, v1.4s, #31
193 ; CHECK-NEXT: shl v3.4s, v0.4s, #31
194 ; CHECK-NEXT: sshr v0.4s, v1.4s, #31
195 ; CHECK-NEXT: sshr v1.4s, v3.4s, #31
196 ; CHECK-NEXT: str q2, [x0]
198 %t = call {<8 x i16>, <8 x i1>} @llvm.uadd.with.overflow.v8i16(<8 x i16> %a0, <8 x i16> %a1)
199 %val = extractvalue {<8 x i16>, <8 x i1>} %t, 0
200 %obit = extractvalue {<8 x i16>, <8 x i1>} %t, 1
201 %res = sext <8 x i1> %obit to <8 x i32>
202 store <8 x i16> %val, <8 x i16>* %p2
206 define <2 x i32> @uaddo_v2i64(<2 x i64> %a0, <2 x i64> %a1, <2 x i64>* %p2) nounwind {
207 ; CHECK-LABEL: uaddo_v2i64:
209 ; CHECK-NEXT: add v1.2d, v0.2d, v1.2d
210 ; CHECK-NEXT: cmhi v0.2d, v0.2d, v1.2d
211 ; CHECK-NEXT: xtn v0.2s, v0.2d
212 ; CHECK-NEXT: str q1, [x0]
214 %t = call {<2 x i64>, <2 x i1>} @llvm.uadd.with.overflow.v2i64(<2 x i64> %a0, <2 x i64> %a1)
215 %val = extractvalue {<2 x i64>, <2 x i1>} %t, 0
216 %obit = extractvalue {<2 x i64>, <2 x i1>} %t, 1
217 %res = sext <2 x i1> %obit to <2 x i32>
218 store <2 x i64> %val, <2 x i64>* %p2
222 define <4 x i32> @uaddo_v4i24(<4 x i24> %a0, <4 x i24> %a1, <4 x i24>* %p2) nounwind {
223 ; CHECK-LABEL: uaddo_v4i24:
225 ; CHECK-NEXT: bic v1.4s, #255, lsl #24
226 ; CHECK-NEXT: bic v0.4s, #255, lsl #24
227 ; CHECK-NEXT: add v0.4s, v0.4s, v1.4s
228 ; CHECK-NEXT: mov v1.16b, v0.16b
229 ; CHECK-NEXT: mov w8, v0.s[3]
230 ; CHECK-NEXT: bic v1.4s, #255, lsl #24
231 ; CHECK-NEXT: mov w9, v0.s[2]
232 ; CHECK-NEXT: mov w10, v0.s[1]
233 ; CHECK-NEXT: sturh w8, [x0, #9]
234 ; CHECK-NEXT: lsr w8, w8, #16
235 ; CHECK-NEXT: cmeq v1.4s, v1.4s, v0.4s
236 ; CHECK-NEXT: fmov w11, s0
237 ; CHECK-NEXT: strh w9, [x0, #6]
238 ; CHECK-NEXT: sturh w10, [x0, #3]
239 ; CHECK-NEXT: lsr w9, w9, #16
240 ; CHECK-NEXT: lsr w10, w10, #16
241 ; CHECK-NEXT: strb w8, [x0, #11]
242 ; CHECK-NEXT: mvn v0.16b, v1.16b
243 ; CHECK-NEXT: lsr w8, w11, #16
244 ; CHECK-NEXT: strh w11, [x0]
245 ; CHECK-NEXT: strb w9, [x0, #8]
246 ; CHECK-NEXT: strb w10, [x0, #5]
247 ; CHECK-NEXT: strb w8, [x0, #2]
249 %t = call {<4 x i24>, <4 x i1>} @llvm.uadd.with.overflow.v4i24(<4 x i24> %a0, <4 x i24> %a1)
250 %val = extractvalue {<4 x i24>, <4 x i1>} %t, 0
251 %obit = extractvalue {<4 x i24>, <4 x i1>} %t, 1
252 %res = sext <4 x i1> %obit to <4 x i32>
253 store <4 x i24> %val, <4 x i24>* %p2
257 define <4 x i32> @uaddo_v4i1(<4 x i1> %a0, <4 x i1> %a1, <4 x i1>* %p2) nounwind {
258 ; CHECK-LABEL: uaddo_v4i1:
260 ; CHECK-NEXT: movi v2.4h, #1
261 ; CHECK-NEXT: and v1.8b, v1.8b, v2.8b
262 ; CHECK-NEXT: and v0.8b, v0.8b, v2.8b
263 ; CHECK-NEXT: add v1.4h, v0.4h, v1.4h
264 ; CHECK-NEXT: umov w9, v1.h[1]
265 ; CHECK-NEXT: umov w8, v1.h[0]
266 ; CHECK-NEXT: and w9, w9, #0x1
267 ; CHECK-NEXT: bfi w8, w9, #1, #1
268 ; CHECK-NEXT: umov w9, v1.h[2]
269 ; CHECK-NEXT: and v0.8b, v1.8b, v2.8b
270 ; CHECK-NEXT: and w9, w9, #0x1
271 ; CHECK-NEXT: cmeq v0.4h, v0.4h, v1.4h
272 ; CHECK-NEXT: bfi w8, w9, #2, #1
273 ; CHECK-NEXT: umov w9, v1.h[3]
274 ; CHECK-NEXT: mvn v0.8b, v0.8b
275 ; CHECK-NEXT: bfi w8, w9, #3, #29
276 ; CHECK-NEXT: sshll v0.4s, v0.4h, #0
277 ; CHECK-NEXT: and w8, w8, #0xf
278 ; CHECK-NEXT: strb w8, [x0]
280 %t = call {<4 x i1>, <4 x i1>} @llvm.uadd.with.overflow.v4i1(<4 x i1> %a0, <4 x i1> %a1)
281 %val = extractvalue {<4 x i1>, <4 x i1>} %t, 0
282 %obit = extractvalue {<4 x i1>, <4 x i1>} %t, 1
283 %res = sext <4 x i1> %obit to <4 x i32>
284 store <4 x i1> %val, <4 x i1>* %p2
288 define <2 x i32> @uaddo_v2i128(<2 x i128> %a0, <2 x i128> %a1, <2 x i128>* %p2) nounwind {
289 ; CHECK-LABEL: uaddo_v2i128:
291 ; CHECK-NEXT: adds x9, x2, x6
292 ; CHECK-NEXT: adcs x10, x3, x7
293 ; CHECK-NEXT: cmp x9, x2
294 ; CHECK-NEXT: cset w11, lo
295 ; CHECK-NEXT: cmp x10, x3
296 ; CHECK-NEXT: cset w12, lo
297 ; CHECK-NEXT: csel w11, w11, w12, eq
298 ; CHECK-NEXT: adds x12, x0, x4
299 ; CHECK-NEXT: adcs x13, x1, x5
300 ; CHECK-NEXT: cmp x12, x0
301 ; CHECK-NEXT: cset w14, lo
302 ; CHECK-NEXT: cmp x13, x1
303 ; CHECK-NEXT: cset w15, lo
304 ; CHECK-NEXT: csel w14, w14, w15, eq
305 ; CHECK-NEXT: ldr x8, [sp]
306 ; CHECK-NEXT: fmov s0, w14
307 ; CHECK-NEXT: mov v0.s[1], w11
308 ; CHECK-NEXT: shl v0.2s, v0.2s, #31
309 ; CHECK-NEXT: sshr v0.2s, v0.2s, #31
310 ; CHECK-NEXT: stp x9, x10, [x8, #16]
311 ; CHECK-NEXT: stp x12, x13, [x8]
313 %t = call {<2 x i128>, <2 x i1>} @llvm.uadd.with.overflow.v2i128(<2 x i128> %a0, <2 x i128> %a1)
314 %val = extractvalue {<2 x i128>, <2 x i1>} %t, 0
315 %obit = extractvalue {<2 x i128>, <2 x i1>} %t, 1
316 %res = sext <2 x i1> %obit to <2 x i32>
317 store <2 x i128> %val, <2 x i128>* %p2