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.uadd.sat.v1i8(<1 x i8>, <1 x i8>)
5 declare <2 x i8> @llvm.uadd.sat.v2i8(<2 x i8>, <2 x i8>)
6 declare <4 x i8> @llvm.uadd.sat.v4i8(<4 x i8>, <4 x i8>)
7 declare <8 x i8> @llvm.uadd.sat.v8i8(<8 x i8>, <8 x i8>)
8 declare <12 x i8> @llvm.uadd.sat.v12i8(<12 x i8>, <12 x i8>)
9 declare <16 x i8> @llvm.uadd.sat.v16i8(<16 x i8>, <16 x i8>)
10 declare <32 x i8> @llvm.uadd.sat.v32i8(<32 x i8>, <32 x i8>)
11 declare <64 x i8> @llvm.uadd.sat.v64i8(<64 x i8>, <64 x i8>)
13 declare <1 x i16> @llvm.uadd.sat.v1i16(<1 x i16>, <1 x i16>)
14 declare <2 x i16> @llvm.uadd.sat.v2i16(<2 x i16>, <2 x i16>)
15 declare <4 x i16> @llvm.uadd.sat.v4i16(<4 x i16>, <4 x i16>)
16 declare <8 x i16> @llvm.uadd.sat.v8i16(<8 x i16>, <8 x i16>)
17 declare <12 x i16> @llvm.uadd.sat.v12i16(<12 x i16>, <12 x i16>)
18 declare <16 x i16> @llvm.uadd.sat.v16i16(<16 x i16>, <16 x i16>)
19 declare <32 x i16> @llvm.uadd.sat.v32i16(<32 x i16>, <32 x i16>)
21 declare <16 x i1> @llvm.uadd.sat.v16i1(<16 x i1>, <16 x i1>)
22 declare <16 x i4> @llvm.uadd.sat.v16i4(<16 x i4>, <16 x i4>)
24 declare <2 x i32> @llvm.uadd.sat.v2i32(<2 x i32>, <2 x i32>)
25 declare <4 x i32> @llvm.uadd.sat.v4i32(<4 x i32>, <4 x i32>)
26 declare <8 x i32> @llvm.uadd.sat.v8i32(<8 x i32>, <8 x i32>)
27 declare <16 x i32> @llvm.uadd.sat.v16i32(<16 x i32>, <16 x i32>)
28 declare <2 x i64> @llvm.uadd.sat.v2i64(<2 x i64>, <2 x i64>)
29 declare <4 x i64> @llvm.uadd.sat.v4i64(<4 x i64>, <4 x i64>)
30 declare <8 x i64> @llvm.uadd.sat.v8i64(<8 x i64>, <8 x i64>)
32 declare <4 x i24> @llvm.uadd.sat.v4i24(<4 x i24>, <4 x i24>)
33 declare <2 x i128> @llvm.uadd.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: uqadd v0.16b, v0.16b, v1.16b
40 %z = call <16 x i8> @llvm.uadd.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: uqadd v1.16b, v1.16b, v3.16b
48 ; CHECK-NEXT: uqadd v0.16b, v0.16b, v2.16b
50 %z = call <32 x i8> @llvm.uadd.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: uqadd v2.16b, v2.16b, v6.16b
58 ; CHECK-NEXT: uqadd v0.16b, v0.16b, v4.16b
59 ; CHECK-NEXT: uqadd v1.16b, v1.16b, v5.16b
60 ; CHECK-NEXT: uqadd v3.16b, v3.16b, v7.16b
62 %z = call <64 x i8> @llvm.uadd.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: uqadd v0.8h, v0.8h, v1.8h
71 %z = call <8 x i16> @llvm.uadd.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: uqadd v1.8h, v1.8h, v3.8h
79 ; CHECK-NEXT: uqadd v0.8h, v0.8h, v2.8h
81 %z = call <16 x i16> @llvm.uadd.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: uqadd v2.8h, v2.8h, v6.8h
89 ; CHECK-NEXT: uqadd v0.8h, v0.8h, v4.8h
90 ; CHECK-NEXT: uqadd v1.8h, v1.8h, v5.8h
91 ; CHECK-NEXT: uqadd v3.8h, v3.8h, v7.8h
93 %z = call <32 x i16> @llvm.uadd.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: uqadd 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.uadd.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 s1, [x0]
116 ; CHECK-NEXT: ldr s2, [x1]
117 ; CHECK-NEXT: movi d0, #0xff00ff00ff00ff
118 ; CHECK-NEXT: uaddl v1.8h, v1.8b, v2.8b
119 ; CHECK-NEXT: umin v0.4h, v1.4h, v0.4h
120 ; CHECK-NEXT: xtn v0.8b, v0.8h
121 ; CHECK-NEXT: str s0, [x2]
123 %x = load <4 x i8>, ptr %px
124 %y = load <4 x i8>, ptr %py
125 %z = call <4 x i8> @llvm.uadd.sat.v4i8(<4 x i8> %x, <4 x i8> %y)
126 store <4 x i8> %z, ptr %pz
130 define void @v2i8(ptr %px, ptr %py, ptr %pz) nounwind {
133 ; CHECK-NEXT: ldrb w8, [x0]
134 ; CHECK-NEXT: ldrb w9, [x1]
135 ; CHECK-NEXT: movi d2, #0x0000ff000000ff
136 ; CHECK-NEXT: ldrb w10, [x0, #1]
137 ; CHECK-NEXT: ldrb w11, [x1, #1]
138 ; CHECK-NEXT: fmov s0, w8
139 ; CHECK-NEXT: fmov s1, w9
140 ; CHECK-NEXT: mov v0.s[1], w10
141 ; CHECK-NEXT: mov v1.s[1], w11
142 ; CHECK-NEXT: add v0.2s, v0.2s, v1.2s
143 ; CHECK-NEXT: umin v0.2s, v0.2s, v2.2s
144 ; CHECK-NEXT: mov w8, v0.s[1]
145 ; CHECK-NEXT: fmov w9, s0
146 ; CHECK-NEXT: strb w9, [x2]
147 ; CHECK-NEXT: strb w8, [x2, #1]
149 %x = load <2 x i8>, ptr %px
150 %y = load <2 x i8>, ptr %py
151 %z = call <2 x i8> @llvm.uadd.sat.v2i8(<2 x i8> %x, <2 x i8> %y)
152 store <2 x i8> %z, ptr %pz
156 define void @v4i16(ptr %px, ptr %py, ptr %pz) nounwind {
157 ; CHECK-LABEL: v4i16:
159 ; CHECK-NEXT: ldr d0, [x0]
160 ; CHECK-NEXT: ldr d1, [x1]
161 ; CHECK-NEXT: uqadd v0.4h, v0.4h, v1.4h
162 ; CHECK-NEXT: str d0, [x2]
164 %x = load <4 x i16>, ptr %px
165 %y = load <4 x i16>, ptr %py
166 %z = call <4 x i16> @llvm.uadd.sat.v4i16(<4 x i16> %x, <4 x i16> %y)
167 store <4 x i16> %z, ptr %pz
171 define void @v2i16(ptr %px, ptr %py, ptr %pz) nounwind {
172 ; CHECK-LABEL: v2i16:
174 ; CHECK-NEXT: ldrh w8, [x0]
175 ; CHECK-NEXT: ldrh w9, [x1]
176 ; CHECK-NEXT: movi d2, #0x00ffff0000ffff
177 ; CHECK-NEXT: ldrh w10, [x0, #2]
178 ; CHECK-NEXT: ldrh w11, [x1, #2]
179 ; CHECK-NEXT: fmov s0, w8
180 ; CHECK-NEXT: fmov s1, w9
181 ; CHECK-NEXT: mov v0.s[1], w10
182 ; CHECK-NEXT: mov v1.s[1], w11
183 ; CHECK-NEXT: add v0.2s, v0.2s, v1.2s
184 ; CHECK-NEXT: umin v0.2s, v0.2s, v2.2s
185 ; CHECK-NEXT: mov w8, v0.s[1]
186 ; CHECK-NEXT: fmov w9, s0
187 ; CHECK-NEXT: strh w9, [x2]
188 ; CHECK-NEXT: strh w8, [x2, #2]
190 %x = load <2 x i16>, ptr %px
191 %y = load <2 x i16>, ptr %py
192 %z = call <2 x i16> @llvm.uadd.sat.v2i16(<2 x i16> %x, <2 x i16> %y)
193 store <2 x i16> %z, ptr %pz
197 define <12 x i8> @v12i8(<12 x i8> %x, <12 x i8> %y) nounwind {
198 ; CHECK-LABEL: v12i8:
200 ; CHECK-NEXT: uqadd v0.16b, v0.16b, v1.16b
202 %z = call <12 x i8> @llvm.uadd.sat.v12i8(<12 x i8> %x, <12 x i8> %y)
206 define void @v12i16(ptr %px, ptr %py, ptr %pz) nounwind {
207 ; CHECK-LABEL: v12i16:
209 ; CHECK-NEXT: ldp q0, q3, [x1]
210 ; CHECK-NEXT: ldp q1, q2, [x0]
211 ; CHECK-NEXT: uqadd v0.8h, v1.8h, v0.8h
212 ; CHECK-NEXT: uqadd v1.8h, v2.8h, v3.8h
213 ; CHECK-NEXT: str q0, [x2]
214 ; CHECK-NEXT: str d1, [x2, #16]
216 %x = load <12 x i16>, ptr %px
217 %y = load <12 x i16>, ptr %py
218 %z = call <12 x i16> @llvm.uadd.sat.v12i16(<12 x i16> %x, <12 x i16> %y)
219 store <12 x i16> %z, ptr %pz
223 define void @v1i8(ptr %px, ptr %py, ptr %pz) nounwind {
226 ; CHECK-NEXT: ldr b0, [x0]
227 ; CHECK-NEXT: ldr b1, [x1]
228 ; CHECK-NEXT: uqadd v0.8b, v0.8b, v1.8b
229 ; CHECK-NEXT: st1 { v0.b }[0], [x2]
231 %x = load <1 x i8>, ptr %px
232 %y = load <1 x i8>, ptr %py
233 %z = call <1 x i8> @llvm.uadd.sat.v1i8(<1 x i8> %x, <1 x i8> %y)
234 store <1 x i8> %z, ptr %pz
238 define void @v1i16(ptr %px, ptr %py, ptr %pz) nounwind {
239 ; CHECK-LABEL: v1i16:
241 ; CHECK-NEXT: ldr h0, [x0]
242 ; CHECK-NEXT: ldr h1, [x1]
243 ; CHECK-NEXT: uqadd v0.4h, v0.4h, v1.4h
244 ; CHECK-NEXT: str h0, [x2]
246 %x = load <1 x i16>, ptr %px
247 %y = load <1 x i16>, ptr %py
248 %z = call <1 x i16> @llvm.uadd.sat.v1i16(<1 x i16> %x, <1 x i16> %y)
249 store <1 x i16> %z, ptr %pz
253 define <16 x i4> @v16i4(<16 x i4> %x, <16 x i4> %y) nounwind {
254 ; CHECK-LABEL: v16i4:
256 ; CHECK-NEXT: movi v2.16b, #15
257 ; CHECK-NEXT: and v1.16b, v1.16b, v2.16b
258 ; CHECK-NEXT: and v0.16b, v0.16b, v2.16b
259 ; CHECK-NEXT: add v0.16b, v0.16b, v1.16b
260 ; CHECK-NEXT: umin v0.16b, v0.16b, v2.16b
262 %z = call <16 x i4> @llvm.uadd.sat.v16i4(<16 x i4> %x, <16 x i4> %y)
266 define <16 x i1> @v16i1(<16 x i1> %x, <16 x i1> %y) nounwind {
267 ; CHECK-LABEL: v16i1:
269 ; CHECK-NEXT: orr v0.16b, v0.16b, v1.16b
271 %z = call <16 x i1> @llvm.uadd.sat.v16i1(<16 x i1> %x, <16 x i1> %y)
275 define <2 x i32> @v2i32(<2 x i32> %x, <2 x i32> %y) nounwind {
276 ; CHECK-LABEL: v2i32:
278 ; CHECK-NEXT: uqadd v0.2s, v0.2s, v1.2s
280 %z = call <2 x i32> @llvm.uadd.sat.v2i32(<2 x i32> %x, <2 x i32> %y)
284 define <4 x i32> @v4i32(<4 x i32> %x, <4 x i32> %y) nounwind {
285 ; CHECK-LABEL: v4i32:
287 ; CHECK-NEXT: uqadd v0.4s, v0.4s, v1.4s
289 %z = call <4 x i32> @llvm.uadd.sat.v4i32(<4 x i32> %x, <4 x i32> %y)
293 define <8 x i32> @v8i32(<8 x i32> %x, <8 x i32> %y) nounwind {
294 ; CHECK-LABEL: v8i32:
296 ; CHECK-NEXT: uqadd v1.4s, v1.4s, v3.4s
297 ; CHECK-NEXT: uqadd v0.4s, v0.4s, v2.4s
299 %z = call <8 x i32> @llvm.uadd.sat.v8i32(<8 x i32> %x, <8 x i32> %y)
303 define <16 x i32> @v16i32(<16 x i32> %x, <16 x i32> %y) nounwind {
304 ; CHECK-LABEL: v16i32:
306 ; CHECK-NEXT: uqadd v2.4s, v2.4s, v6.4s
307 ; CHECK-NEXT: uqadd v0.4s, v0.4s, v4.4s
308 ; CHECK-NEXT: uqadd v1.4s, v1.4s, v5.4s
309 ; CHECK-NEXT: uqadd v3.4s, v3.4s, v7.4s
311 %z = call <16 x i32> @llvm.uadd.sat.v16i32(<16 x i32> %x, <16 x i32> %y)
315 define <2 x i64> @v2i64(<2 x i64> %x, <2 x i64> %y) nounwind {
316 ; CHECK-LABEL: v2i64:
318 ; CHECK-NEXT: uqadd v0.2d, v0.2d, v1.2d
320 %z = call <2 x i64> @llvm.uadd.sat.v2i64(<2 x i64> %x, <2 x i64> %y)
324 define <4 x i64> @v4i64(<4 x i64> %x, <4 x i64> %y) nounwind {
325 ; CHECK-LABEL: v4i64:
327 ; CHECK-NEXT: uqadd v1.2d, v1.2d, v3.2d
328 ; CHECK-NEXT: uqadd v0.2d, v0.2d, v2.2d
330 %z = call <4 x i64> @llvm.uadd.sat.v4i64(<4 x i64> %x, <4 x i64> %y)
334 define <8 x i64> @v8i64(<8 x i64> %x, <8 x i64> %y) nounwind {
335 ; CHECK-LABEL: v8i64:
337 ; CHECK-NEXT: uqadd v2.2d, v2.2d, v6.2d
338 ; CHECK-NEXT: uqadd v0.2d, v0.2d, v4.2d
339 ; CHECK-NEXT: uqadd v1.2d, v1.2d, v5.2d
340 ; CHECK-NEXT: uqadd v3.2d, v3.2d, v7.2d
342 %z = call <8 x i64> @llvm.uadd.sat.v8i64(<8 x i64> %x, <8 x i64> %y)
346 define <2 x i128> @v2i128(<2 x i128> %x, <2 x i128> %y) nounwind {
347 ; CHECK-LABEL: v2i128:
349 ; CHECK-NEXT: adds x8, x2, x6
350 ; CHECK-NEXT: adcs x9, x3, x7
351 ; CHECK-NEXT: csinv x2, x8, xzr, lo
352 ; CHECK-NEXT: csinv x3, x9, xzr, lo
353 ; CHECK-NEXT: adds x8, x0, x4
354 ; CHECK-NEXT: adcs x9, x1, x5
355 ; CHECK-NEXT: csinv x8, x8, xzr, lo
356 ; CHECK-NEXT: csinv x1, x9, xzr, lo
357 ; CHECK-NEXT: fmov d0, x8
358 ; CHECK-NEXT: mov v0.d[1], x1
359 ; CHECK-NEXT: fmov x0, d0
361 %z = call <2 x i128> @llvm.uadd.sat.v2i128(<2 x i128> %x, <2 x i128> %y)