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: add v2.16b, v0.16b, v1.16b
39 ; CHECK-NEXT: cmlt v4.16b, v2.16b, #0
40 ; CHECK-NEXT: movi v3.16b, #127
41 ; CHECK-NEXT: cmlt v1.16b, v1.16b, #0
42 ; CHECK-NEXT: cmgt v0.16b, v0.16b, v2.16b
43 ; CHECK-NEXT: mvn v5.16b, v4.16b
44 ; CHECK-NEXT: bsl v3.16b, v4.16b, v5.16b
45 ; CHECK-NEXT: eor v0.16b, v1.16b, v0.16b
46 ; CHECK-NEXT: bsl v0.16b, v3.16b, v2.16b
48 %z = call <16 x i8> @llvm.sadd.sat.v16i8(<16 x i8> %x, <16 x i8> %y)
52 define <32 x i8> @v32i8(<32 x i8> %x, <32 x i8> %y) nounwind {
55 ; CHECK-NEXT: add v4.16b, v0.16b, v2.16b
56 ; CHECK-NEXT: cmlt v7.16b, v4.16b, #0
57 ; CHECK-NEXT: movi v6.16b, #127
58 ; CHECK-NEXT: mvn v16.16b, v7.16b
59 ; CHECK-NEXT: bsl v6.16b, v7.16b, v16.16b
60 ; CHECK-NEXT: add v7.16b, v1.16b, v3.16b
61 ; CHECK-NEXT: cmlt v2.16b, v2.16b, #0
62 ; CHECK-NEXT: cmgt v0.16b, v0.16b, v4.16b
63 ; CHECK-NEXT: cmlt v16.16b, v7.16b, #0
64 ; CHECK-NEXT: movi v5.16b, #127
65 ; CHECK-NEXT: cmlt v3.16b, v3.16b, #0
66 ; CHECK-NEXT: cmgt v1.16b, v1.16b, v7.16b
67 ; CHECK-NEXT: eor v0.16b, v2.16b, v0.16b
68 ; CHECK-NEXT: mvn v2.16b, v16.16b
69 ; CHECK-NEXT: eor v1.16b, v3.16b, v1.16b
70 ; CHECK-NEXT: bsl v5.16b, v16.16b, v2.16b
71 ; CHECK-NEXT: bsl v0.16b, v6.16b, v4.16b
72 ; CHECK-NEXT: bsl v1.16b, v5.16b, v7.16b
74 %z = call <32 x i8> @llvm.sadd.sat.v32i8(<32 x i8> %x, <32 x i8> %y)
78 define <64 x i8> @v64i8(<64 x i8> %x, <64 x i8> %y) nounwind {
81 ; CHECK-NEXT: add v16.16b, v0.16b, v4.16b
82 ; CHECK-NEXT: cmlt v24.16b, v16.16b, #0
83 ; CHECK-NEXT: movi v18.16b, #127
84 ; CHECK-NEXT: add v19.16b, v1.16b, v5.16b
85 ; CHECK-NEXT: mvn v25.16b, v24.16b
86 ; CHECK-NEXT: bsl v18.16b, v24.16b, v25.16b
87 ; CHECK-NEXT: cmlt v24.16b, v19.16b, #0
88 ; CHECK-NEXT: movi v20.16b, #127
89 ; CHECK-NEXT: add v21.16b, v2.16b, v6.16b
90 ; CHECK-NEXT: mvn v25.16b, v24.16b
91 ; CHECK-NEXT: bsl v20.16b, v24.16b, v25.16b
92 ; CHECK-NEXT: cmlt v24.16b, v21.16b, #0
93 ; CHECK-NEXT: cmlt v4.16b, v4.16b, #0
94 ; CHECK-NEXT: cmgt v0.16b, v0.16b, v16.16b
95 ; CHECK-NEXT: movi v22.16b, #127
96 ; CHECK-NEXT: add v23.16b, v3.16b, v7.16b
97 ; CHECK-NEXT: mvn v25.16b, v24.16b
98 ; CHECK-NEXT: eor v0.16b, v4.16b, v0.16b
99 ; CHECK-NEXT: cmlt v4.16b, v5.16b, #0
100 ; CHECK-NEXT: cmgt v1.16b, v1.16b, v19.16b
101 ; CHECK-NEXT: bsl v22.16b, v24.16b, v25.16b
102 ; CHECK-NEXT: cmlt v24.16b, v23.16b, #0
103 ; CHECK-NEXT: eor v1.16b, v4.16b, v1.16b
104 ; CHECK-NEXT: cmlt v4.16b, v6.16b, #0
105 ; CHECK-NEXT: cmgt v2.16b, v2.16b, v21.16b
106 ; CHECK-NEXT: movi v17.16b, #127
107 ; CHECK-NEXT: mvn v25.16b, v24.16b
108 ; CHECK-NEXT: eor v2.16b, v4.16b, v2.16b
109 ; CHECK-NEXT: cmlt v4.16b, v7.16b, #0
110 ; CHECK-NEXT: cmgt v3.16b, v3.16b, v23.16b
111 ; CHECK-NEXT: bsl v17.16b, v24.16b, v25.16b
112 ; CHECK-NEXT: eor v3.16b, v4.16b, v3.16b
113 ; CHECK-NEXT: bsl v0.16b, v18.16b, v16.16b
114 ; CHECK-NEXT: bsl v1.16b, v20.16b, v19.16b
115 ; CHECK-NEXT: bsl v2.16b, v22.16b, v21.16b
116 ; CHECK-NEXT: bsl v3.16b, v17.16b, v23.16b
118 %z = call <64 x i8> @llvm.sadd.sat.v64i8(<64 x i8> %x, <64 x i8> %y)
122 define <8 x i16> @v8i16(<8 x i16> %x, <8 x i16> %y) nounwind {
123 ; CHECK-LABEL: v8i16:
125 ; CHECK-NEXT: add v2.8h, v0.8h, v1.8h
126 ; CHECK-NEXT: cmlt v4.8h, v2.8h, #0
127 ; CHECK-NEXT: mvni v3.8h, #128, lsl #8
128 ; CHECK-NEXT: cmlt v1.8h, v1.8h, #0
129 ; CHECK-NEXT: cmgt v0.8h, v0.8h, v2.8h
130 ; CHECK-NEXT: mvn v5.16b, v4.16b
131 ; CHECK-NEXT: bsl v3.16b, v4.16b, v5.16b
132 ; CHECK-NEXT: eor v0.16b, v1.16b, v0.16b
133 ; CHECK-NEXT: bsl v0.16b, v3.16b, v2.16b
135 %z = call <8 x i16> @llvm.sadd.sat.v8i16(<8 x i16> %x, <8 x i16> %y)
139 define <16 x i16> @v16i16(<16 x i16> %x, <16 x i16> %y) nounwind {
140 ; CHECK-LABEL: v16i16:
142 ; CHECK-NEXT: add v4.8h, v0.8h, v2.8h
143 ; CHECK-NEXT: cmlt v7.8h, v4.8h, #0
144 ; CHECK-NEXT: mvni v6.8h, #128, lsl #8
145 ; CHECK-NEXT: mvn v16.16b, v7.16b
146 ; CHECK-NEXT: bsl v6.16b, v7.16b, v16.16b
147 ; CHECK-NEXT: add v7.8h, v1.8h, v3.8h
148 ; CHECK-NEXT: cmlt v2.8h, v2.8h, #0
149 ; CHECK-NEXT: cmgt v0.8h, v0.8h, v4.8h
150 ; CHECK-NEXT: cmlt v16.8h, v7.8h, #0
151 ; CHECK-NEXT: mvni v5.8h, #128, lsl #8
152 ; CHECK-NEXT: cmlt v3.8h, v3.8h, #0
153 ; CHECK-NEXT: cmgt v1.8h, v1.8h, v7.8h
154 ; CHECK-NEXT: eor v0.16b, v2.16b, v0.16b
155 ; CHECK-NEXT: mvn v2.16b, v16.16b
156 ; CHECK-NEXT: eor v1.16b, v3.16b, v1.16b
157 ; CHECK-NEXT: bsl v5.16b, v16.16b, v2.16b
158 ; CHECK-NEXT: bsl v0.16b, v6.16b, v4.16b
159 ; CHECK-NEXT: bsl v1.16b, v5.16b, v7.16b
161 %z = call <16 x i16> @llvm.sadd.sat.v16i16(<16 x i16> %x, <16 x i16> %y)
165 define <32 x i16> @v32i16(<32 x i16> %x, <32 x i16> %y) nounwind {
166 ; CHECK-LABEL: v32i16:
168 ; CHECK-NEXT: add v16.8h, v0.8h, v4.8h
169 ; CHECK-NEXT: cmlt v24.8h, v16.8h, #0
170 ; CHECK-NEXT: mvni v18.8h, #128, lsl #8
171 ; CHECK-NEXT: add v19.8h, v1.8h, v5.8h
172 ; CHECK-NEXT: mvn v25.16b, v24.16b
173 ; CHECK-NEXT: bsl v18.16b, v24.16b, v25.16b
174 ; CHECK-NEXT: cmlt v24.8h, v19.8h, #0
175 ; CHECK-NEXT: mvni v20.8h, #128, lsl #8
176 ; CHECK-NEXT: add v21.8h, v2.8h, v6.8h
177 ; CHECK-NEXT: mvn v25.16b, v24.16b
178 ; CHECK-NEXT: bsl v20.16b, v24.16b, v25.16b
179 ; CHECK-NEXT: cmlt v24.8h, v21.8h, #0
180 ; CHECK-NEXT: cmlt v4.8h, v4.8h, #0
181 ; CHECK-NEXT: cmgt v0.8h, v0.8h, v16.8h
182 ; CHECK-NEXT: mvni v22.8h, #128, lsl #8
183 ; CHECK-NEXT: add v23.8h, v3.8h, v7.8h
184 ; CHECK-NEXT: mvn v25.16b, v24.16b
185 ; CHECK-NEXT: eor v0.16b, v4.16b, v0.16b
186 ; CHECK-NEXT: cmlt v4.8h, v5.8h, #0
187 ; CHECK-NEXT: cmgt v1.8h, v1.8h, v19.8h
188 ; CHECK-NEXT: bsl v22.16b, v24.16b, v25.16b
189 ; CHECK-NEXT: cmlt v24.8h, v23.8h, #0
190 ; CHECK-NEXT: eor v1.16b, v4.16b, v1.16b
191 ; CHECK-NEXT: cmlt v4.8h, v6.8h, #0
192 ; CHECK-NEXT: cmgt v2.8h, v2.8h, v21.8h
193 ; CHECK-NEXT: mvni v17.8h, #128, lsl #8
194 ; CHECK-NEXT: mvn v25.16b, v24.16b
195 ; CHECK-NEXT: eor v2.16b, v4.16b, v2.16b
196 ; CHECK-NEXT: cmlt v4.8h, v7.8h, #0
197 ; CHECK-NEXT: cmgt v3.8h, v3.8h, v23.8h
198 ; CHECK-NEXT: bsl v17.16b, v24.16b, v25.16b
199 ; CHECK-NEXT: eor v3.16b, v4.16b, v3.16b
200 ; CHECK-NEXT: bsl v0.16b, v18.16b, v16.16b
201 ; CHECK-NEXT: bsl v1.16b, v20.16b, v19.16b
202 ; CHECK-NEXT: bsl v2.16b, v22.16b, v21.16b
203 ; CHECK-NEXT: bsl v3.16b, v17.16b, v23.16b
205 %z = call <32 x i16> @llvm.sadd.sat.v32i16(<32 x i16> %x, <32 x i16> %y)
209 define void @v8i8(<8 x i8>* %px, <8 x i8>* %py, <8 x i8>* %pz) nounwind {
212 ; CHECK-NEXT: ldr d0, [x0]
213 ; CHECK-NEXT: ldr d1, [x1]
214 ; CHECK-NEXT: movi v2.8b, #127
215 ; CHECK-NEXT: add v3.8b, v0.8b, v1.8b
216 ; CHECK-NEXT: cmlt v4.8b, v3.8b, #0
217 ; CHECK-NEXT: cmlt v1.8b, v1.8b, #0
218 ; CHECK-NEXT: cmgt v0.8b, v0.8b, v3.8b
219 ; CHECK-NEXT: mvn v5.8b, v4.8b
220 ; CHECK-NEXT: bsl v2.8b, v4.8b, v5.8b
221 ; CHECK-NEXT: eor v0.8b, v1.8b, v0.8b
222 ; CHECK-NEXT: bsl v0.8b, v2.8b, v3.8b
223 ; CHECK-NEXT: str d0, [x2]
225 %x = load <8 x i8>, <8 x i8>* %px
226 %y = load <8 x i8>, <8 x i8>* %py
227 %z = call <8 x i8> @llvm.sadd.sat.v8i8(<8 x i8> %x, <8 x i8> %y)
228 store <8 x i8> %z, <8 x i8>* %pz
232 define void @v4i8(<4 x i8>* %px, <4 x i8>* %py, <4 x i8>* %pz) nounwind {
235 ; CHECK-NEXT: ldrb w8, [x0]
236 ; CHECK-NEXT: ldrb w9, [x1]
237 ; CHECK-NEXT: ldrb w10, [x0, #1]
238 ; CHECK-NEXT: ldrb w11, [x1, #1]
239 ; CHECK-NEXT: ldrb w12, [x0, #2]
240 ; CHECK-NEXT: fmov s0, w8
241 ; CHECK-NEXT: ldrb w8, [x1, #2]
242 ; CHECK-NEXT: fmov s1, w9
243 ; CHECK-NEXT: mov v0.h[1], w10
244 ; CHECK-NEXT: ldrb w9, [x0, #3]
245 ; CHECK-NEXT: ldrb w10, [x1, #3]
246 ; CHECK-NEXT: mov v1.h[1], w11
247 ; CHECK-NEXT: mov v0.h[2], w12
248 ; CHECK-NEXT: mov v1.h[2], w8
249 ; CHECK-NEXT: mov v0.h[3], w9
250 ; CHECK-NEXT: mov v1.h[3], w10
251 ; CHECK-NEXT: shl v1.4h, v1.4h, #8
252 ; CHECK-NEXT: shl v0.4h, v0.4h, #8
253 ; CHECK-NEXT: add v3.4h, v0.4h, v1.4h
254 ; CHECK-NEXT: cmlt v4.4h, v3.4h, #0
255 ; CHECK-NEXT: mvni v2.4h, #128, lsl #8
256 ; CHECK-NEXT: cmlt v1.4h, v1.4h, #0
257 ; CHECK-NEXT: cmgt v0.4h, v0.4h, v3.4h
258 ; CHECK-NEXT: mvn v5.8b, v4.8b
259 ; CHECK-NEXT: bsl v2.8b, v4.8b, v5.8b
260 ; CHECK-NEXT: eor v0.8b, v1.8b, v0.8b
261 ; CHECK-NEXT: bsl v0.8b, v2.8b, v3.8b
262 ; CHECK-NEXT: sshr v0.4h, v0.4h, #8
263 ; CHECK-NEXT: xtn v0.8b, v0.8h
264 ; CHECK-NEXT: str s0, [x2]
266 %x = load <4 x i8>, <4 x i8>* %px
267 %y = load <4 x i8>, <4 x i8>* %py
268 %z = call <4 x i8> @llvm.sadd.sat.v4i8(<4 x i8> %x, <4 x i8> %y)
269 store <4 x i8> %z, <4 x i8>* %pz
273 define void @v2i8(<2 x i8>* %px, <2 x i8>* %py, <2 x i8>* %pz) nounwind {
276 ; CHECK-NEXT: ldrb w8, [x0]
277 ; CHECK-NEXT: ldrb w9, [x1]
278 ; CHECK-NEXT: ldrb w10, [x0, #1]
279 ; CHECK-NEXT: ldrb w11, [x1, #1]
280 ; CHECK-NEXT: fmov s0, w8
281 ; CHECK-NEXT: fmov s2, w9
282 ; CHECK-NEXT: mov v0.s[1], w10
283 ; CHECK-NEXT: mov v2.s[1], w11
284 ; CHECK-NEXT: shl v2.2s, v2.2s, #24
285 ; CHECK-NEXT: shl v0.2s, v0.2s, #24
286 ; CHECK-NEXT: add v3.2s, v0.2s, v2.2s
287 ; CHECK-NEXT: cmlt v4.2s, v3.2s, #0
288 ; CHECK-NEXT: mvni v1.2s, #128, lsl #24
289 ; CHECK-NEXT: cmlt v2.2s, v2.2s, #0
290 ; CHECK-NEXT: cmgt v0.2s, v0.2s, v3.2s
291 ; CHECK-NEXT: mvn v5.8b, v4.8b
292 ; CHECK-NEXT: eor v0.8b, v2.8b, v0.8b
293 ; CHECK-NEXT: bsl v1.8b, v4.8b, v5.8b
294 ; CHECK-NEXT: bsl v0.8b, v1.8b, v3.8b
295 ; CHECK-NEXT: ushr v0.2s, v0.2s, #24
296 ; CHECK-NEXT: mov w8, v0.s[1]
297 ; CHECK-NEXT: fmov w9, s0
298 ; CHECK-NEXT: strb w8, [x2, #1]
299 ; CHECK-NEXT: strb w9, [x2]
301 %x = load <2 x i8>, <2 x i8>* %px
302 %y = load <2 x i8>, <2 x i8>* %py
303 %z = call <2 x i8> @llvm.sadd.sat.v2i8(<2 x i8> %x, <2 x i8> %y)
304 store <2 x i8> %z, <2 x i8>* %pz
308 define void @v4i16(<4 x i16>* %px, <4 x i16>* %py, <4 x i16>* %pz) nounwind {
309 ; CHECK-LABEL: v4i16:
311 ; CHECK-NEXT: ldr d0, [x0]
312 ; CHECK-NEXT: ldr d1, [x1]
313 ; CHECK-NEXT: mvni v2.4h, #128, lsl #8
314 ; CHECK-NEXT: add v3.4h, v0.4h, v1.4h
315 ; CHECK-NEXT: cmlt v4.4h, v3.4h, #0
316 ; CHECK-NEXT: cmlt v1.4h, v1.4h, #0
317 ; CHECK-NEXT: cmgt v0.4h, v0.4h, v3.4h
318 ; CHECK-NEXT: mvn v5.8b, v4.8b
319 ; CHECK-NEXT: bsl v2.8b, v4.8b, v5.8b
320 ; CHECK-NEXT: eor v0.8b, v1.8b, v0.8b
321 ; CHECK-NEXT: bsl v0.8b, v2.8b, v3.8b
322 ; CHECK-NEXT: str d0, [x2]
324 %x = load <4 x i16>, <4 x i16>* %px
325 %y = load <4 x i16>, <4 x i16>* %py
326 %z = call <4 x i16> @llvm.sadd.sat.v4i16(<4 x i16> %x, <4 x i16> %y)
327 store <4 x i16> %z, <4 x i16>* %pz
331 define void @v2i16(<2 x i16>* %px, <2 x i16>* %py, <2 x i16>* %pz) nounwind {
332 ; CHECK-LABEL: v2i16:
334 ; CHECK-NEXT: ldrh w8, [x0]
335 ; CHECK-NEXT: ldrh w9, [x1]
336 ; CHECK-NEXT: ldrh w10, [x0, #2]
337 ; CHECK-NEXT: ldrh w11, [x1, #2]
338 ; CHECK-NEXT: fmov s0, w8
339 ; CHECK-NEXT: fmov s2, w9
340 ; CHECK-NEXT: mov v0.s[1], w10
341 ; CHECK-NEXT: mov v2.s[1], w11
342 ; CHECK-NEXT: shl v2.2s, v2.2s, #16
343 ; CHECK-NEXT: shl v0.2s, v0.2s, #16
344 ; CHECK-NEXT: add v3.2s, v0.2s, v2.2s
345 ; CHECK-NEXT: cmlt v4.2s, v3.2s, #0
346 ; CHECK-NEXT: mvni v1.2s, #128, lsl #24
347 ; CHECK-NEXT: cmlt v2.2s, v2.2s, #0
348 ; CHECK-NEXT: cmgt v0.2s, v0.2s, v3.2s
349 ; CHECK-NEXT: mvn v5.8b, v4.8b
350 ; CHECK-NEXT: eor v0.8b, v2.8b, v0.8b
351 ; CHECK-NEXT: bsl v1.8b, v4.8b, v5.8b
352 ; CHECK-NEXT: bsl v0.8b, v1.8b, v3.8b
353 ; CHECK-NEXT: ushr v0.2s, v0.2s, #16
354 ; CHECK-NEXT: mov w8, v0.s[1]
355 ; CHECK-NEXT: fmov w9, s0
356 ; CHECK-NEXT: strh w8, [x2, #2]
357 ; CHECK-NEXT: strh w9, [x2]
359 %x = load <2 x i16>, <2 x i16>* %px
360 %y = load <2 x i16>, <2 x i16>* %py
361 %z = call <2 x i16> @llvm.sadd.sat.v2i16(<2 x i16> %x, <2 x i16> %y)
362 store <2 x i16> %z, <2 x i16>* %pz
366 define <12 x i8> @v12i8(<12 x i8> %x, <12 x i8> %y) nounwind {
367 ; CHECK-LABEL: v12i8:
369 ; CHECK-NEXT: add v2.16b, v0.16b, v1.16b
370 ; CHECK-NEXT: cmlt v4.16b, v2.16b, #0
371 ; CHECK-NEXT: movi v3.16b, #127
372 ; CHECK-NEXT: cmlt v1.16b, v1.16b, #0
373 ; CHECK-NEXT: cmgt v0.16b, v0.16b, v2.16b
374 ; CHECK-NEXT: mvn v5.16b, v4.16b
375 ; CHECK-NEXT: bsl v3.16b, v4.16b, v5.16b
376 ; CHECK-NEXT: eor v0.16b, v1.16b, v0.16b
377 ; CHECK-NEXT: bsl v0.16b, v3.16b, v2.16b
379 %z = call <12 x i8> @llvm.sadd.sat.v12i8(<12 x i8> %x, <12 x i8> %y)
383 define void @v12i16(<12 x i16>* %px, <12 x i16>* %py, <12 x i16>* %pz) nounwind {
384 ; CHECK-LABEL: v12i16:
386 ; CHECK-NEXT: ldp q0, q1, [x0]
387 ; CHECK-NEXT: ldp q3, q2, [x1]
388 ; CHECK-NEXT: mvni v5.8h, #128, lsl #8
389 ; CHECK-NEXT: mvni v4.8h, #128, lsl #8
390 ; CHECK-NEXT: add v6.8h, v1.8h, v2.8h
391 ; CHECK-NEXT: cmlt v7.8h, v6.8h, #0
392 ; CHECK-NEXT: mvn v16.16b, v7.16b
393 ; CHECK-NEXT: bsl v5.16b, v7.16b, v16.16b
394 ; CHECK-NEXT: add v7.8h, v0.8h, v3.8h
395 ; CHECK-NEXT: cmlt v2.8h, v2.8h, #0
396 ; CHECK-NEXT: cmgt v1.8h, v1.8h, v6.8h
397 ; CHECK-NEXT: cmlt v16.8h, v7.8h, #0
398 ; CHECK-NEXT: cmlt v3.8h, v3.8h, #0
399 ; CHECK-NEXT: cmgt v0.8h, v0.8h, v7.8h
400 ; CHECK-NEXT: eor v1.16b, v2.16b, v1.16b
401 ; CHECK-NEXT: mvn v2.16b, v16.16b
402 ; CHECK-NEXT: eor v0.16b, v3.16b, v0.16b
403 ; CHECK-NEXT: bsl v4.16b, v16.16b, v2.16b
404 ; CHECK-NEXT: bsl v1.16b, v5.16b, v6.16b
405 ; CHECK-NEXT: bsl v0.16b, v4.16b, v7.16b
406 ; CHECK-NEXT: str q0, [x2]
407 ; CHECK-NEXT: str d1, [x2, #16]
409 %x = load <12 x i16>, <12 x i16>* %px
410 %y = load <12 x i16>, <12 x i16>* %py
411 %z = call <12 x i16> @llvm.sadd.sat.v12i16(<12 x i16> %x, <12 x i16> %y)
412 store <12 x i16> %z, <12 x i16>* %pz
416 define void @v1i8(<1 x i8>* %px, <1 x i8>* %py, <1 x i8>* %pz) nounwind {
419 ; CHECK-NEXT: ldr b0, [x0]
420 ; CHECK-NEXT: ldr b1, [x1]
421 ; CHECK-NEXT: movi v2.8b, #127
422 ; CHECK-NEXT: add v3.8b, v0.8b, v1.8b
423 ; CHECK-NEXT: cmlt v4.8b, v3.8b, #0
424 ; CHECK-NEXT: cmlt v1.8b, v1.8b, #0
425 ; CHECK-NEXT: cmgt v0.8b, v0.8b, v3.8b
426 ; CHECK-NEXT: mvn v5.8b, v4.8b
427 ; CHECK-NEXT: bsl v2.8b, v4.8b, v5.8b
428 ; CHECK-NEXT: eor v0.8b, v1.8b, v0.8b
429 ; CHECK-NEXT: bsl v0.8b, v2.8b, v3.8b
430 ; CHECK-NEXT: st1 { v0.b }[0], [x2]
432 %x = load <1 x i8>, <1 x i8>* %px
433 %y = load <1 x i8>, <1 x i8>* %py
434 %z = call <1 x i8> @llvm.sadd.sat.v1i8(<1 x i8> %x, <1 x i8> %y)
435 store <1 x i8> %z, <1 x i8>* %pz
439 define void @v1i16(<1 x i16>* %px, <1 x i16>* %py, <1 x i16>* %pz) nounwind {
440 ; CHECK-LABEL: v1i16:
442 ; CHECK-NEXT: ldr h0, [x0]
443 ; CHECK-NEXT: ldr h1, [x1]
444 ; CHECK-NEXT: mvni v2.4h, #128, lsl #8
445 ; CHECK-NEXT: add v3.4h, v0.4h, v1.4h
446 ; CHECK-NEXT: cmlt v4.4h, v3.4h, #0
447 ; CHECK-NEXT: cmlt v1.4h, v1.4h, #0
448 ; CHECK-NEXT: cmgt v0.4h, v0.4h, v3.4h
449 ; CHECK-NEXT: mvn v5.8b, v4.8b
450 ; CHECK-NEXT: bsl v2.8b, v4.8b, v5.8b
451 ; CHECK-NEXT: eor v0.8b, v1.8b, v0.8b
452 ; CHECK-NEXT: bsl v0.8b, v2.8b, v3.8b
453 ; CHECK-NEXT: str h0, [x2]
455 %x = load <1 x i16>, <1 x i16>* %px
456 %y = load <1 x i16>, <1 x i16>* %py
457 %z = call <1 x i16> @llvm.sadd.sat.v1i16(<1 x i16> %x, <1 x i16> %y)
458 store <1 x i16> %z, <1 x i16>* %pz
462 define <16 x i4> @v16i4(<16 x i4> %x, <16 x i4> %y) nounwind {
463 ; CHECK-LABEL: v16i4:
465 ; CHECK-NEXT: shl v1.16b, v1.16b, #4
466 ; CHECK-NEXT: shl v0.16b, v0.16b, #4
467 ; CHECK-NEXT: add v3.16b, v0.16b, v1.16b
468 ; CHECK-NEXT: cmlt v4.16b, v3.16b, #0
469 ; CHECK-NEXT: movi v2.16b, #127
470 ; CHECK-NEXT: cmlt v1.16b, v1.16b, #0
471 ; CHECK-NEXT: cmgt v0.16b, v0.16b, v3.16b
472 ; CHECK-NEXT: mvn v5.16b, v4.16b
473 ; CHECK-NEXT: bsl v2.16b, v4.16b, v5.16b
474 ; CHECK-NEXT: eor v0.16b, v1.16b, v0.16b
475 ; CHECK-NEXT: bsl v0.16b, v2.16b, v3.16b
476 ; CHECK-NEXT: sshr v0.16b, v0.16b, #4
478 %z = call <16 x i4> @llvm.sadd.sat.v16i4(<16 x i4> %x, <16 x i4> %y)
482 define <16 x i1> @v16i1(<16 x i1> %x, <16 x i1> %y) nounwind {
483 ; CHECK-LABEL: v16i1:
485 ; CHECK-NEXT: shl v1.16b, v1.16b, #7
486 ; CHECK-NEXT: shl v0.16b, v0.16b, #7
487 ; CHECK-NEXT: add v3.16b, v0.16b, v1.16b
488 ; CHECK-NEXT: cmlt v4.16b, v3.16b, #0
489 ; CHECK-NEXT: movi v2.16b, #127
490 ; CHECK-NEXT: cmlt v1.16b, v1.16b, #0
491 ; CHECK-NEXT: cmgt v0.16b, v0.16b, v3.16b
492 ; CHECK-NEXT: mvn v5.16b, v4.16b
493 ; CHECK-NEXT: bsl v2.16b, v4.16b, v5.16b
494 ; CHECK-NEXT: eor v0.16b, v1.16b, v0.16b
495 ; CHECK-NEXT: bsl v0.16b, v2.16b, v3.16b
496 ; CHECK-NEXT: sshr v0.16b, v0.16b, #7
498 %z = call <16 x i1> @llvm.sadd.sat.v16i1(<16 x i1> %x, <16 x i1> %y)
502 define <2 x i32> @v2i32(<2 x i32> %x, <2 x i32> %y) nounwind {
503 ; CHECK-LABEL: v2i32:
505 ; CHECK-NEXT: add v2.2s, v0.2s, v1.2s
506 ; CHECK-NEXT: cmlt v4.2s, v2.2s, #0
507 ; CHECK-NEXT: mvni v3.2s, #128, lsl #24
508 ; CHECK-NEXT: cmlt v1.2s, v1.2s, #0
509 ; CHECK-NEXT: cmgt v0.2s, v0.2s, v2.2s
510 ; CHECK-NEXT: mvn v5.8b, v4.8b
511 ; CHECK-NEXT: bsl v3.8b, v4.8b, v5.8b
512 ; CHECK-NEXT: eor v0.8b, v1.8b, v0.8b
513 ; CHECK-NEXT: bsl v0.8b, v3.8b, v2.8b
515 %z = call <2 x i32> @llvm.sadd.sat.v2i32(<2 x i32> %x, <2 x i32> %y)
519 define <4 x i32> @v4i32(<4 x i32> %x, <4 x i32> %y) nounwind {
520 ; CHECK-LABEL: v4i32:
522 ; CHECK-NEXT: add v2.4s, v0.4s, v1.4s
523 ; CHECK-NEXT: cmlt v4.4s, v2.4s, #0
524 ; CHECK-NEXT: mvni v3.4s, #128, lsl #24
525 ; CHECK-NEXT: cmlt v1.4s, v1.4s, #0
526 ; CHECK-NEXT: cmgt v0.4s, v0.4s, v2.4s
527 ; CHECK-NEXT: mvn v5.16b, v4.16b
528 ; CHECK-NEXT: bsl v3.16b, v4.16b, v5.16b
529 ; CHECK-NEXT: eor v0.16b, v1.16b, v0.16b
530 ; CHECK-NEXT: bsl v0.16b, v3.16b, v2.16b
532 %z = call <4 x i32> @llvm.sadd.sat.v4i32(<4 x i32> %x, <4 x i32> %y)
536 define <8 x i32> @v8i32(<8 x i32> %x, <8 x i32> %y) nounwind {
537 ; CHECK-LABEL: v8i32:
539 ; CHECK-NEXT: add v4.4s, v0.4s, v2.4s
540 ; CHECK-NEXT: cmlt v7.4s, v4.4s, #0
541 ; CHECK-NEXT: mvni v6.4s, #128, lsl #24
542 ; CHECK-NEXT: mvn v16.16b, v7.16b
543 ; CHECK-NEXT: bsl v6.16b, v7.16b, v16.16b
544 ; CHECK-NEXT: add v7.4s, v1.4s, v3.4s
545 ; CHECK-NEXT: cmlt v2.4s, v2.4s, #0
546 ; CHECK-NEXT: cmgt v0.4s, v0.4s, v4.4s
547 ; CHECK-NEXT: cmlt v16.4s, v7.4s, #0
548 ; CHECK-NEXT: mvni v5.4s, #128, lsl #24
549 ; CHECK-NEXT: cmlt v3.4s, v3.4s, #0
550 ; CHECK-NEXT: cmgt v1.4s, v1.4s, v7.4s
551 ; CHECK-NEXT: eor v0.16b, v2.16b, v0.16b
552 ; CHECK-NEXT: mvn v2.16b, v16.16b
553 ; CHECK-NEXT: eor v1.16b, v3.16b, v1.16b
554 ; CHECK-NEXT: bsl v5.16b, v16.16b, v2.16b
555 ; CHECK-NEXT: bsl v0.16b, v6.16b, v4.16b
556 ; CHECK-NEXT: bsl v1.16b, v5.16b, v7.16b
558 %z = call <8 x i32> @llvm.sadd.sat.v8i32(<8 x i32> %x, <8 x i32> %y)
562 define <16 x i32> @v16i32(<16 x i32> %x, <16 x i32> %y) nounwind {
563 ; CHECK-LABEL: v16i32:
565 ; CHECK-NEXT: add v16.4s, v0.4s, v4.4s
566 ; CHECK-NEXT: cmlt v24.4s, v16.4s, #0
567 ; CHECK-NEXT: mvni v18.4s, #128, lsl #24
568 ; CHECK-NEXT: add v19.4s, v1.4s, v5.4s
569 ; CHECK-NEXT: mvn v25.16b, v24.16b
570 ; CHECK-NEXT: bsl v18.16b, v24.16b, v25.16b
571 ; CHECK-NEXT: cmlt v24.4s, v19.4s, #0
572 ; CHECK-NEXT: mvni v20.4s, #128, lsl #24
573 ; CHECK-NEXT: add v21.4s, v2.4s, v6.4s
574 ; CHECK-NEXT: mvn v25.16b, v24.16b
575 ; CHECK-NEXT: bsl v20.16b, v24.16b, v25.16b
576 ; CHECK-NEXT: cmlt v24.4s, v21.4s, #0
577 ; CHECK-NEXT: cmlt v4.4s, v4.4s, #0
578 ; CHECK-NEXT: cmgt v0.4s, v0.4s, v16.4s
579 ; CHECK-NEXT: mvni v22.4s, #128, lsl #24
580 ; CHECK-NEXT: add v23.4s, v3.4s, v7.4s
581 ; CHECK-NEXT: mvn v25.16b, v24.16b
582 ; CHECK-NEXT: eor v0.16b, v4.16b, v0.16b
583 ; CHECK-NEXT: cmlt v4.4s, v5.4s, #0
584 ; CHECK-NEXT: cmgt v1.4s, v1.4s, v19.4s
585 ; CHECK-NEXT: bsl v22.16b, v24.16b, v25.16b
586 ; CHECK-NEXT: cmlt v24.4s, v23.4s, #0
587 ; CHECK-NEXT: eor v1.16b, v4.16b, v1.16b
588 ; CHECK-NEXT: cmlt v4.4s, v6.4s, #0
589 ; CHECK-NEXT: cmgt v2.4s, v2.4s, v21.4s
590 ; CHECK-NEXT: mvni v17.4s, #128, lsl #24
591 ; CHECK-NEXT: mvn v25.16b, v24.16b
592 ; CHECK-NEXT: eor v2.16b, v4.16b, v2.16b
593 ; CHECK-NEXT: cmlt v4.4s, v7.4s, #0
594 ; CHECK-NEXT: cmgt v3.4s, v3.4s, v23.4s
595 ; CHECK-NEXT: bsl v17.16b, v24.16b, v25.16b
596 ; CHECK-NEXT: eor v3.16b, v4.16b, v3.16b
597 ; CHECK-NEXT: bsl v0.16b, v18.16b, v16.16b
598 ; CHECK-NEXT: bsl v1.16b, v20.16b, v19.16b
599 ; CHECK-NEXT: bsl v2.16b, v22.16b, v21.16b
600 ; CHECK-NEXT: bsl v3.16b, v17.16b, v23.16b
602 %z = call <16 x i32> @llvm.sadd.sat.v16i32(<16 x i32> %x, <16 x i32> %y)
606 define <2 x i64> @v2i64(<2 x i64> %x, <2 x i64> %y) nounwind {
607 ; CHECK-LABEL: v2i64:
609 ; CHECK-NEXT: add v2.2d, v0.2d, v1.2d
610 ; CHECK-NEXT: mov x8, #9223372036854775807
611 ; CHECK-NEXT: cmlt v3.2d, v2.2d, #0
612 ; CHECK-NEXT: cmlt v1.2d, v1.2d, #0
613 ; CHECK-NEXT: dup v4.2d, x8
614 ; CHECK-NEXT: cmgt v0.2d, v0.2d, v2.2d
615 ; CHECK-NEXT: mvn v5.16b, v3.16b
616 ; CHECK-NEXT: bsl v4.16b, v3.16b, v5.16b
617 ; CHECK-NEXT: eor v0.16b, v1.16b, v0.16b
618 ; CHECK-NEXT: bsl v0.16b, v4.16b, v2.16b
620 %z = call <2 x i64> @llvm.sadd.sat.v2i64(<2 x i64> %x, <2 x i64> %y)
624 define <4 x i64> @v4i64(<4 x i64> %x, <4 x i64> %y) nounwind {
625 ; CHECK-LABEL: v4i64:
627 ; CHECK-NEXT: add v4.2d, v0.2d, v2.2d
628 ; CHECK-NEXT: mov x8, #9223372036854775807
629 ; CHECK-NEXT: cmlt v5.2d, v4.2d, #0
630 ; CHECK-NEXT: dup v6.2d, x8
631 ; CHECK-NEXT: mvn v7.16b, v5.16b
632 ; CHECK-NEXT: mov v16.16b, v6.16b
633 ; CHECK-NEXT: bsl v16.16b, v5.16b, v7.16b
634 ; CHECK-NEXT: add v5.2d, v1.2d, v3.2d
635 ; CHECK-NEXT: cmlt v2.2d, v2.2d, #0
636 ; CHECK-NEXT: cmgt v0.2d, v0.2d, v4.2d
637 ; CHECK-NEXT: cmlt v7.2d, v5.2d, #0
638 ; CHECK-NEXT: cmlt v3.2d, v3.2d, #0
639 ; CHECK-NEXT: cmgt v1.2d, v1.2d, v5.2d
640 ; CHECK-NEXT: eor v0.16b, v2.16b, v0.16b
641 ; CHECK-NEXT: mvn v2.16b, v7.16b
642 ; CHECK-NEXT: eor v1.16b, v3.16b, v1.16b
643 ; CHECK-NEXT: bsl v6.16b, v7.16b, v2.16b
644 ; CHECK-NEXT: bsl v0.16b, v16.16b, v4.16b
645 ; CHECK-NEXT: bsl v1.16b, v6.16b, v5.16b
647 %z = call <4 x i64> @llvm.sadd.sat.v4i64(<4 x i64> %x, <4 x i64> %y)
651 define <8 x i64> @v8i64(<8 x i64> %x, <8 x i64> %y) nounwind {
652 ; CHECK-LABEL: v8i64:
654 ; CHECK-NEXT: add v16.2d, v0.2d, v4.2d
655 ; CHECK-NEXT: mov x8, #9223372036854775807
656 ; CHECK-NEXT: add v17.2d, v1.2d, v5.2d
657 ; CHECK-NEXT: cmlt v20.2d, v16.2d, #0
658 ; CHECK-NEXT: dup v21.2d, x8
659 ; CHECK-NEXT: add v18.2d, v2.2d, v6.2d
660 ; CHECK-NEXT: cmlt v22.2d, v17.2d, #0
661 ; CHECK-NEXT: mvn v24.16b, v20.16b
662 ; CHECK-NEXT: mov v25.16b, v21.16b
663 ; CHECK-NEXT: cmlt v23.2d, v18.2d, #0
664 ; CHECK-NEXT: bsl v25.16b, v20.16b, v24.16b
665 ; CHECK-NEXT: mvn v20.16b, v22.16b
666 ; CHECK-NEXT: mov v24.16b, v21.16b
667 ; CHECK-NEXT: cmlt v4.2d, v4.2d, #0
668 ; CHECK-NEXT: cmgt v0.2d, v0.2d, v16.2d
669 ; CHECK-NEXT: add v19.2d, v3.2d, v7.2d
670 ; CHECK-NEXT: bsl v24.16b, v22.16b, v20.16b
671 ; CHECK-NEXT: mvn v20.16b, v23.16b
672 ; CHECK-NEXT: mov v22.16b, v21.16b
673 ; CHECK-NEXT: eor v0.16b, v4.16b, v0.16b
674 ; CHECK-NEXT: cmlt v4.2d, v5.2d, #0
675 ; CHECK-NEXT: cmgt v1.2d, v1.2d, v17.2d
676 ; CHECK-NEXT: bsl v22.16b, v23.16b, v20.16b
677 ; CHECK-NEXT: cmlt v20.2d, v19.2d, #0
678 ; CHECK-NEXT: eor v1.16b, v4.16b, v1.16b
679 ; CHECK-NEXT: cmlt v4.2d, v6.2d, #0
680 ; CHECK-NEXT: cmgt v2.2d, v2.2d, v18.2d
681 ; CHECK-NEXT: mvn v23.16b, v20.16b
682 ; CHECK-NEXT: eor v2.16b, v4.16b, v2.16b
683 ; CHECK-NEXT: cmlt v4.2d, v7.2d, #0
684 ; CHECK-NEXT: cmgt v3.2d, v3.2d, v19.2d
685 ; CHECK-NEXT: bsl v21.16b, v20.16b, v23.16b
686 ; CHECK-NEXT: eor v3.16b, v4.16b, v3.16b
687 ; CHECK-NEXT: bsl v0.16b, v25.16b, v16.16b
688 ; CHECK-NEXT: bsl v1.16b, v24.16b, v17.16b
689 ; CHECK-NEXT: bsl v2.16b, v22.16b, v18.16b
690 ; CHECK-NEXT: bsl v3.16b, v21.16b, v19.16b
692 %z = call <8 x i64> @llvm.sadd.sat.v8i64(<8 x i64> %x, <8 x i64> %y)
696 define <2 x i128> @v2i128(<2 x i128> %x, <2 x i128> %y) nounwind {
697 ; CHECK-LABEL: v2i128:
699 ; CHECK-NEXT: cmp x7, #0 // =0
700 ; CHECK-NEXT: cset w9, ge
701 ; CHECK-NEXT: csinc w9, w9, wzr, ne
702 ; CHECK-NEXT: cmp x3, #0 // =0
703 ; CHECK-NEXT: cset w10, ge
704 ; CHECK-NEXT: csinc w10, w10, wzr, ne
705 ; CHECK-NEXT: cmp w10, w9
706 ; CHECK-NEXT: cset w9, eq
707 ; CHECK-NEXT: adds x11, x2, x6
708 ; CHECK-NEXT: adcs x12, x3, x7
709 ; CHECK-NEXT: cmp x12, #0 // =0
710 ; CHECK-NEXT: cset w13, ge
711 ; CHECK-NEXT: mov x8, #9223372036854775807
712 ; CHECK-NEXT: csinc w13, w13, wzr, ne
713 ; CHECK-NEXT: cinv x14, x8, ge
714 ; CHECK-NEXT: cmp w10, w13
715 ; CHECK-NEXT: cset w13, ne
716 ; CHECK-NEXT: asr x10, x12, #63
717 ; CHECK-NEXT: tst w9, w13
718 ; CHECK-NEXT: csel x3, x14, x12, ne
719 ; CHECK-NEXT: csel x2, x10, x11, ne
720 ; CHECK-NEXT: cmp x5, #0 // =0
721 ; CHECK-NEXT: cset w9, ge
722 ; CHECK-NEXT: csinc w9, w9, wzr, ne
723 ; CHECK-NEXT: cmp x1, #0 // =0
724 ; CHECK-NEXT: cset w10, ge
725 ; CHECK-NEXT: csinc w10, w10, wzr, ne
726 ; CHECK-NEXT: cmp w10, w9
727 ; CHECK-NEXT: cset w9, eq
728 ; CHECK-NEXT: adds x11, x0, x4
729 ; CHECK-NEXT: adcs x12, x1, x5
730 ; CHECK-NEXT: cmp x12, #0 // =0
731 ; CHECK-NEXT: cset w13, ge
732 ; CHECK-NEXT: csinc w13, w13, wzr, ne
733 ; CHECK-NEXT: cinv x8, x8, ge
734 ; CHECK-NEXT: cmp w10, w13
735 ; CHECK-NEXT: cset w10, ne
736 ; CHECK-NEXT: tst w9, w10
737 ; CHECK-NEXT: asr x9, x12, #63
738 ; CHECK-NEXT: csel x9, x9, x11, ne
739 ; CHECK-NEXT: csel x1, x8, x12, ne
740 ; CHECK-NEXT: fmov d0, x9
741 ; CHECK-NEXT: mov v0.d[1], x1
742 ; CHECK-NEXT: fmov x0, d0
744 %z = call <2 x i128> @llvm.sadd.sat.v2i128(<2 x i128> %x, <2 x i128> %y)