1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=aarch64-- | FileCheck %s
4 declare <1 x i8> @llvm.sadd.sat.v1i8(<1 x i8>, <1 x i8>)
5 declare <2 x i8> @llvm.sadd.sat.v2i8(<2 x i8>, <2 x i8>)
6 declare <4 x i8> @llvm.sadd.sat.v4i8(<4 x i8>, <4 x i8>)
7 declare <8 x i8> @llvm.sadd.sat.v8i8(<8 x i8>, <8 x i8>)
8 declare <12 x i8> @llvm.sadd.sat.v12i8(<12 x i8>, <12 x i8>)
9 declare <16 x i8> @llvm.sadd.sat.v16i8(<16 x i8>, <16 x i8>)
10 declare <32 x i8> @llvm.sadd.sat.v32i8(<32 x i8>, <32 x i8>)
11 declare <64 x i8> @llvm.sadd.sat.v64i8(<64 x i8>, <64 x i8>)
13 declare <1 x i16> @llvm.sadd.sat.v1i16(<1 x i16>, <1 x i16>)
14 declare <2 x i16> @llvm.sadd.sat.v2i16(<2 x i16>, <2 x i16>)
15 declare <4 x i16> @llvm.sadd.sat.v4i16(<4 x i16>, <4 x i16>)
16 declare <8 x i16> @llvm.sadd.sat.v8i16(<8 x i16>, <8 x i16>)
17 declare <12 x i16> @llvm.sadd.sat.v12i16(<12 x i16>, <12 x i16>)
18 declare <16 x i16> @llvm.sadd.sat.v16i16(<16 x i16>, <16 x i16>)
19 declare <32 x i16> @llvm.sadd.sat.v32i16(<32 x i16>, <32 x i16>)
21 declare <16 x i1> @llvm.sadd.sat.v16i1(<16 x i1>, <16 x i1>)
22 declare <16 x i4> @llvm.sadd.sat.v16i4(<16 x i4>, <16 x i4>)
24 declare <2 x i32> @llvm.sadd.sat.v2i32(<2 x i32>, <2 x i32>)
25 declare <4 x i32> @llvm.sadd.sat.v4i32(<4 x i32>, <4 x i32>)
26 declare <8 x i32> @llvm.sadd.sat.v8i32(<8 x i32>, <8 x i32>)
27 declare <16 x i32> @llvm.sadd.sat.v16i32(<16 x i32>, <16 x i32>)
28 declare <2 x i64> @llvm.sadd.sat.v2i64(<2 x i64>, <2 x i64>)
29 declare <4 x i64> @llvm.sadd.sat.v4i64(<4 x i64>, <4 x i64>)
30 declare <8 x i64> @llvm.sadd.sat.v8i64(<8 x i64>, <8 x i64>)
32 declare <4 x i24> @llvm.sadd.sat.v4i24(<4 x i24>, <4 x i24>)
33 declare <2 x i128> @llvm.sadd.sat.v2i128(<2 x i128>, <2 x i128>)
35 define <16 x i8> @v16i8(<16 x i8> %x, <16 x i8> %y) nounwind {
38 ; CHECK-NEXT: sqadd v0.16b, v0.16b, v1.16b
40 %z = call <16 x i8> @llvm.sadd.sat.v16i8(<16 x i8> %x, <16 x i8> %y)
44 define <32 x i8> @v32i8(<32 x i8> %x, <32 x i8> %y) nounwind {
47 ; CHECK-NEXT: sqadd v1.16b, v1.16b, v3.16b
48 ; CHECK-NEXT: sqadd v0.16b, v0.16b, v2.16b
50 %z = call <32 x i8> @llvm.sadd.sat.v32i8(<32 x i8> %x, <32 x i8> %y)
54 define <64 x i8> @v64i8(<64 x i8> %x, <64 x i8> %y) nounwind {
57 ; CHECK-NEXT: sqadd v2.16b, v2.16b, v6.16b
58 ; CHECK-NEXT: sqadd v0.16b, v0.16b, v4.16b
59 ; CHECK-NEXT: sqadd v1.16b, v1.16b, v5.16b
60 ; CHECK-NEXT: sqadd v3.16b, v3.16b, v7.16b
62 %z = call <64 x i8> @llvm.sadd.sat.v64i8(<64 x i8> %x, <64 x i8> %y)
66 define <8 x i16> @v8i16(<8 x i16> %x, <8 x i16> %y) nounwind {
69 ; CHECK-NEXT: sqadd v0.8h, v0.8h, v1.8h
71 %z = call <8 x i16> @llvm.sadd.sat.v8i16(<8 x i16> %x, <8 x i16> %y)
75 define <16 x i16> @v16i16(<16 x i16> %x, <16 x i16> %y) nounwind {
76 ; CHECK-LABEL: v16i16:
78 ; CHECK-NEXT: sqadd v1.8h, v1.8h, v3.8h
79 ; CHECK-NEXT: sqadd v0.8h, v0.8h, v2.8h
81 %z = call <16 x i16> @llvm.sadd.sat.v16i16(<16 x i16> %x, <16 x i16> %y)
85 define <32 x i16> @v32i16(<32 x i16> %x, <32 x i16> %y) nounwind {
86 ; CHECK-LABEL: v32i16:
88 ; CHECK-NEXT: sqadd v2.8h, v2.8h, v6.8h
89 ; CHECK-NEXT: sqadd v0.8h, v0.8h, v4.8h
90 ; CHECK-NEXT: sqadd v1.8h, v1.8h, v5.8h
91 ; CHECK-NEXT: sqadd v3.8h, v3.8h, v7.8h
93 %z = call <32 x i16> @llvm.sadd.sat.v32i16(<32 x i16> %x, <32 x i16> %y)
97 define void @v8i8(ptr %px, ptr %py, ptr %pz) nounwind {
100 ; CHECK-NEXT: ldr d0, [x0]
101 ; CHECK-NEXT: ldr d1, [x1]
102 ; CHECK-NEXT: sqadd v0.8b, v0.8b, v1.8b
103 ; CHECK-NEXT: str d0, [x2]
105 %x = load <8 x i8>, ptr %px
106 %y = load <8 x i8>, ptr %py
107 %z = call <8 x i8> @llvm.sadd.sat.v8i8(<8 x i8> %x, <8 x i8> %y)
108 store <8 x i8> %z, ptr %pz
112 define void @v4i8(ptr %px, ptr %py, ptr %pz) nounwind {
115 ; CHECK-NEXT: ldr s0, [x0]
116 ; CHECK-NEXT: ldr s1, [x1]
117 ; CHECK-NEXT: sshll v0.8h, v0.8b, #0
118 ; CHECK-NEXT: sshll v1.8h, v1.8b, #0
119 ; CHECK-NEXT: shl v1.4h, v1.4h, #8
120 ; CHECK-NEXT: shl v0.4h, v0.4h, #8
121 ; CHECK-NEXT: sqadd v0.4h, v0.4h, v1.4h
122 ; CHECK-NEXT: sshr v0.4h, v0.4h, #8
123 ; CHECK-NEXT: xtn v0.8b, v0.8h
124 ; CHECK-NEXT: str s0, [x2]
126 %x = load <4 x i8>, ptr %px
127 %y = load <4 x i8>, ptr %py
128 %z = call <4 x i8> @llvm.sadd.sat.v4i8(<4 x i8> %x, <4 x i8> %y)
129 store <4 x i8> %z, ptr %pz
133 define void @v2i8(ptr %px, ptr %py, ptr %pz) nounwind {
136 ; CHECK-NEXT: ld1 { v0.b }[0], [x0]
137 ; CHECK-NEXT: ld1 { v1.b }[0], [x1]
138 ; CHECK-NEXT: add x8, x0, #1
139 ; CHECK-NEXT: add x9, x1, #1
140 ; CHECK-NEXT: ld1 { v0.b }[4], [x8]
141 ; CHECK-NEXT: ld1 { v1.b }[4], [x9]
142 ; CHECK-NEXT: shl v1.2s, v1.2s, #24
143 ; CHECK-NEXT: shl v0.2s, v0.2s, #24
144 ; CHECK-NEXT: sqadd v0.2s, v0.2s, v1.2s
145 ; CHECK-NEXT: ushr v0.2s, v0.2s, #24
146 ; CHECK-NEXT: mov w8, v0.s[1]
147 ; CHECK-NEXT: fmov w9, s0
148 ; CHECK-NEXT: strb w9, [x2]
149 ; CHECK-NEXT: strb w8, [x2, #1]
151 %x = load <2 x i8>, ptr %px
152 %y = load <2 x i8>, ptr %py
153 %z = call <2 x i8> @llvm.sadd.sat.v2i8(<2 x i8> %x, <2 x i8> %y)
154 store <2 x i8> %z, ptr %pz
158 define void @v4i16(ptr %px, ptr %py, ptr %pz) nounwind {
159 ; CHECK-LABEL: v4i16:
161 ; CHECK-NEXT: ldr d0, [x0]
162 ; CHECK-NEXT: ldr d1, [x1]
163 ; CHECK-NEXT: sqadd v0.4h, v0.4h, v1.4h
164 ; CHECK-NEXT: str d0, [x2]
166 %x = load <4 x i16>, ptr %px
167 %y = load <4 x i16>, ptr %py
168 %z = call <4 x i16> @llvm.sadd.sat.v4i16(<4 x i16> %x, <4 x i16> %y)
169 store <4 x i16> %z, ptr %pz
173 define void @v2i16(ptr %px, ptr %py, ptr %pz) nounwind {
174 ; CHECK-LABEL: v2i16:
176 ; CHECK-NEXT: ld1 { v0.h }[0], [x0]
177 ; CHECK-NEXT: ld1 { v1.h }[0], [x1]
178 ; CHECK-NEXT: add x8, x0, #2
179 ; CHECK-NEXT: add x9, x1, #2
180 ; CHECK-NEXT: ld1 { v0.h }[2], [x8]
181 ; CHECK-NEXT: ld1 { v1.h }[2], [x9]
182 ; CHECK-NEXT: shl v1.2s, v1.2s, #16
183 ; CHECK-NEXT: shl v0.2s, v0.2s, #16
184 ; CHECK-NEXT: sqadd v0.2s, v0.2s, v1.2s
185 ; CHECK-NEXT: ushr v0.2s, v0.2s, #16
186 ; CHECK-NEXT: mov w8, v0.s[1]
187 ; CHECK-NEXT: fmov w9, s0
188 ; CHECK-NEXT: strh w9, [x2]
189 ; CHECK-NEXT: strh w8, [x2, #2]
191 %x = load <2 x i16>, ptr %px
192 %y = load <2 x i16>, ptr %py
193 %z = call <2 x i16> @llvm.sadd.sat.v2i16(<2 x i16> %x, <2 x i16> %y)
194 store <2 x i16> %z, ptr %pz
198 define <12 x i8> @v12i8(<12 x i8> %x, <12 x i8> %y) nounwind {
199 ; CHECK-LABEL: v12i8:
201 ; CHECK-NEXT: sqadd v0.16b, v0.16b, v1.16b
203 %z = call <12 x i8> @llvm.sadd.sat.v12i8(<12 x i8> %x, <12 x i8> %y)
207 define void @v12i16(ptr %px, ptr %py, ptr %pz) nounwind {
208 ; CHECK-LABEL: v12i16:
210 ; CHECK-NEXT: ldp q0, q3, [x1]
211 ; CHECK-NEXT: ldp q1, q2, [x0]
212 ; CHECK-NEXT: sqadd v0.8h, v1.8h, v0.8h
213 ; CHECK-NEXT: sqadd v1.8h, v2.8h, v3.8h
214 ; CHECK-NEXT: str q0, [x2]
215 ; CHECK-NEXT: str d1, [x2, #16]
217 %x = load <12 x i16>, ptr %px
218 %y = load <12 x i16>, ptr %py
219 %z = call <12 x i16> @llvm.sadd.sat.v12i16(<12 x i16> %x, <12 x i16> %y)
220 store <12 x i16> %z, ptr %pz
224 define void @v1i8(ptr %px, ptr %py, ptr %pz) nounwind {
227 ; CHECK-NEXT: ldr b0, [x0]
228 ; CHECK-NEXT: ldr b1, [x1]
229 ; CHECK-NEXT: sqadd v0.8b, v0.8b, v1.8b
230 ; CHECK-NEXT: st1 { v0.b }[0], [x2]
232 %x = load <1 x i8>, ptr %px
233 %y = load <1 x i8>, ptr %py
234 %z = call <1 x i8> @llvm.sadd.sat.v1i8(<1 x i8> %x, <1 x i8> %y)
235 store <1 x i8> %z, ptr %pz
239 define void @v1i16(ptr %px, ptr %py, ptr %pz) nounwind {
240 ; CHECK-LABEL: v1i16:
242 ; CHECK-NEXT: ldr h0, [x0]
243 ; CHECK-NEXT: ldr h1, [x1]
244 ; CHECK-NEXT: sqadd v0.4h, v0.4h, v1.4h
245 ; CHECK-NEXT: str h0, [x2]
247 %x = load <1 x i16>, ptr %px
248 %y = load <1 x i16>, ptr %py
249 %z = call <1 x i16> @llvm.sadd.sat.v1i16(<1 x i16> %x, <1 x i16> %y)
250 store <1 x i16> %z, ptr %pz
254 define <16 x i4> @v16i4(<16 x i4> %x, <16 x i4> %y) nounwind {
255 ; CHECK-LABEL: v16i4:
257 ; CHECK-NEXT: shl v0.16b, v0.16b, #4
258 ; CHECK-NEXT: shl v1.16b, v1.16b, #4
259 ; CHECK-NEXT: sshr v0.16b, v0.16b, #4
260 ; CHECK-NEXT: sshr v1.16b, v1.16b, #4
261 ; CHECK-NEXT: shl v1.16b, v1.16b, #4
262 ; CHECK-NEXT: shl v0.16b, v0.16b, #4
263 ; CHECK-NEXT: sqadd v0.16b, v0.16b, v1.16b
264 ; CHECK-NEXT: sshr v0.16b, v0.16b, #4
266 %z = call <16 x i4> @llvm.sadd.sat.v16i4(<16 x i4> %x, <16 x i4> %y)
270 define <16 x i1> @v16i1(<16 x i1> %x, <16 x i1> %y) nounwind {
271 ; CHECK-LABEL: v16i1:
273 ; CHECK-NEXT: orr v0.16b, v0.16b, v1.16b
275 %z = call <16 x i1> @llvm.sadd.sat.v16i1(<16 x i1> %x, <16 x i1> %y)
279 define <2 x i32> @v2i32(<2 x i32> %x, <2 x i32> %y) nounwind {
280 ; CHECK-LABEL: v2i32:
282 ; CHECK-NEXT: sqadd v0.2s, v0.2s, v1.2s
284 %z = call <2 x i32> @llvm.sadd.sat.v2i32(<2 x i32> %x, <2 x i32> %y)
288 define <4 x i32> @v4i32(<4 x i32> %x, <4 x i32> %y) nounwind {
289 ; CHECK-LABEL: v4i32:
291 ; CHECK-NEXT: sqadd v0.4s, v0.4s, v1.4s
293 %z = call <4 x i32> @llvm.sadd.sat.v4i32(<4 x i32> %x, <4 x i32> %y)
297 define <8 x i32> @v8i32(<8 x i32> %x, <8 x i32> %y) nounwind {
298 ; CHECK-LABEL: v8i32:
300 ; CHECK-NEXT: sqadd v1.4s, v1.4s, v3.4s
301 ; CHECK-NEXT: sqadd v0.4s, v0.4s, v2.4s
303 %z = call <8 x i32> @llvm.sadd.sat.v8i32(<8 x i32> %x, <8 x i32> %y)
307 define <16 x i32> @v16i32(<16 x i32> %x, <16 x i32> %y) nounwind {
308 ; CHECK-LABEL: v16i32:
310 ; CHECK-NEXT: sqadd v2.4s, v2.4s, v6.4s
311 ; CHECK-NEXT: sqadd v0.4s, v0.4s, v4.4s
312 ; CHECK-NEXT: sqadd v1.4s, v1.4s, v5.4s
313 ; CHECK-NEXT: sqadd v3.4s, v3.4s, v7.4s
315 %z = call <16 x i32> @llvm.sadd.sat.v16i32(<16 x i32> %x, <16 x i32> %y)
319 define <2 x i64> @v2i64(<2 x i64> %x, <2 x i64> %y) nounwind {
320 ; CHECK-LABEL: v2i64:
322 ; CHECK-NEXT: sqadd v0.2d, v0.2d, v1.2d
324 %z = call <2 x i64> @llvm.sadd.sat.v2i64(<2 x i64> %x, <2 x i64> %y)
328 define <4 x i64> @v4i64(<4 x i64> %x, <4 x i64> %y) nounwind {
329 ; CHECK-LABEL: v4i64:
331 ; CHECK-NEXT: sqadd v1.2d, v1.2d, v3.2d
332 ; CHECK-NEXT: sqadd v0.2d, v0.2d, v2.2d
334 %z = call <4 x i64> @llvm.sadd.sat.v4i64(<4 x i64> %x, <4 x i64> %y)
338 define <8 x i64> @v8i64(<8 x i64> %x, <8 x i64> %y) nounwind {
339 ; CHECK-LABEL: v8i64:
341 ; CHECK-NEXT: sqadd v2.2d, v2.2d, v6.2d
342 ; CHECK-NEXT: sqadd v0.2d, v0.2d, v4.2d
343 ; CHECK-NEXT: sqadd v1.2d, v1.2d, v5.2d
344 ; CHECK-NEXT: sqadd v3.2d, v3.2d, v7.2d
346 %z = call <8 x i64> @llvm.sadd.sat.v8i64(<8 x i64> %x, <8 x i64> %y)
350 define <2 x i128> @v2i128(<2 x i128> %x, <2 x i128> %y) nounwind {
351 ; CHECK-LABEL: v2i128:
353 ; CHECK-NEXT: adds x8, x2, x6
354 ; CHECK-NEXT: adcs x9, x3, x7
355 ; CHECK-NEXT: asr x10, x9, #63
356 ; CHECK-NEXT: eor x11, x10, #0x8000000000000000
357 ; CHECK-NEXT: csel x2, x10, x8, vs
358 ; CHECK-NEXT: csel x3, x11, x9, vs
359 ; CHECK-NEXT: adds x8, x0, x4
360 ; CHECK-NEXT: adcs x9, x1, x5
361 ; CHECK-NEXT: asr x10, x9, #63
362 ; CHECK-NEXT: csel x8, x10, x8, vs
363 ; CHECK-NEXT: eor x11, x10, #0x8000000000000000
364 ; CHECK-NEXT: fmov d0, x8
365 ; CHECK-NEXT: csel x1, x11, x9, vs
366 ; CHECK-NEXT: mov v0.d[1], x1
367 ; CHECK-NEXT: fmov x0, d0
369 %z = call <2 x i128> @llvm.sadd.sat.v2i128(<2 x i128> %x, <2 x i128> %y)