1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=aarch64-- | FileCheck %s
4 declare i4 @llvm.sadd.sat.i4 (i4, i4)
5 declare i32 @llvm.sadd.sat.i32 (i32, i32)
6 declare i64 @llvm.sadd.sat.i64 (i64, i64)
7 declare <4 x i32> @llvm.sadd.sat.v4i32(<4 x i32>, <4 x i32>)
9 define i32 @func(i32 %x, i32 %y) nounwind {
12 ; CHECK-NEXT: adds w8, w0, w1
13 ; CHECK-NEXT: mov w9, #2147483647
14 ; CHECK-NEXT: cmp w8, #0 // =0
15 ; CHECK-NEXT: cinv w8, w9, ge
16 ; CHECK-NEXT: adds w9, w0, w1
17 ; CHECK-NEXT: csel w0, w8, w9, vs
19 %tmp = call i32 @llvm.sadd.sat.i32(i32 %x, i32 %y);
23 define i64 @func2(i64 %x, i64 %y) nounwind {
26 ; CHECK-NEXT: adds x8, x0, x1
27 ; CHECK-NEXT: mov x9, #9223372036854775807
28 ; CHECK-NEXT: cmp x8, #0 // =0
29 ; CHECK-NEXT: cinv x8, x9, ge
30 ; CHECK-NEXT: adds x9, x0, x1
31 ; CHECK-NEXT: csel x0, x8, x9, vs
33 %tmp = call i64 @llvm.sadd.sat.i64(i64 %x, i64 %y);
37 define i4 @func3(i4 %x, i4 %y) nounwind {
40 ; CHECK-NEXT: lsl w8, w0, #28
41 ; CHECK-NEXT: adds w10, w8, w1, lsl #28
42 ; CHECK-NEXT: mov w9, #2147483647
43 ; CHECK-NEXT: cmp w10, #0 // =0
44 ; CHECK-NEXT: cinv w9, w9, ge
45 ; CHECK-NEXT: adds w8, w8, w1, lsl #28
46 ; CHECK-NEXT: csel w8, w9, w8, vs
47 ; CHECK-NEXT: asr w0, w8, #28
49 %tmp = call i4 @llvm.sadd.sat.i4(i4 %x, i4 %y);
53 define <4 x i32> @vec(<4 x i32> %x, <4 x i32> %y) nounwind {
56 ; CHECK-NEXT: add v2.4s, v0.4s, v1.4s
57 ; CHECK-NEXT: cmge v1.4s, v1.4s, #0
58 ; CHECK-NEXT: cmge v0.4s, v0.4s, #0
59 ; CHECK-NEXT: cmge v5.4s, v2.4s, #0
60 ; CHECK-NEXT: cmlt v4.4s, v2.4s, #0
61 ; CHECK-NEXT: cmeq v1.4s, v0.4s, v1.4s
62 ; CHECK-NEXT: cmeq v0.4s, v0.4s, v5.4s
63 ; CHECK-NEXT: mvni v3.4s, #128, lsl #24
64 ; CHECK-NEXT: mvn v5.16b, v4.16b
65 ; CHECK-NEXT: mvn v0.16b, v0.16b
66 ; CHECK-NEXT: bsl v3.16b, v4.16b, v5.16b
67 ; CHECK-NEXT: and v0.16b, v1.16b, v0.16b
68 ; CHECK-NEXT: bsl v0.16b, v3.16b, v2.16b
70 %tmp = call <4 x i32> @llvm.sadd.sat.v4i32(<4 x i32> %x, <4 x i32> %y);