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 i8 @llvm.sadd.sat.i8(i8, i8)
6 declare i16 @llvm.sadd.sat.i16(i16, i16)
7 declare i32 @llvm.sadd.sat.i32(i32, i32)
8 declare i64 @llvm.sadd.sat.i64(i64, i64)
9 declare <4 x i32> @llvm.sadd.sat.v4i32(<4 x i32>, <4 x i32>)
11 define i32 @func(i32 %x, i32 %y) nounwind {
14 ; CHECK-NEXT: adds w8, w0, w1
15 ; CHECK-NEXT: asr w9, w8, #31
16 ; CHECK-NEXT: eor w9, w9, #0x80000000
17 ; CHECK-NEXT: csel w0, w9, w8, 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: asr x9, x8, #63
28 ; CHECK-NEXT: eor x9, x9, #0x8000000000000000
29 ; CHECK-NEXT: csel x0, x9, x8, vs
31 %tmp = call i64 @llvm.sadd.sat.i64(i64 %x, i64 %y);
35 define i16 @func16(i16 %x, i16 %y) nounwind {
36 ; CHECK-LABEL: func16:
38 ; CHECK-NEXT: sxth w8, w0
39 ; CHECK-NEXT: mov w9, #32767 // =0x7fff
40 ; CHECK-NEXT: add w8, w8, w1, sxth
41 ; CHECK-NEXT: cmp w8, w9
42 ; CHECK-NEXT: csel w8, w8, w9, lt
43 ; CHECK-NEXT: mov w9, #-32768 // =0xffff8000
44 ; CHECK-NEXT: cmn w8, #8, lsl #12 // =32768
45 ; CHECK-NEXT: csel w0, w8, w9, gt
47 %tmp = call i16 @llvm.sadd.sat.i16(i16 %x, i16 %y);
51 define i8 @func8(i8 %x, i8 %y) nounwind {
54 ; CHECK-NEXT: sxtb w9, w0
55 ; CHECK-NEXT: mov w8, #127 // =0x7f
56 ; CHECK-NEXT: add w9, w9, w1, sxtb
57 ; CHECK-NEXT: cmp w9, #127
58 ; CHECK-NEXT: csel w8, w9, w8, lt
59 ; CHECK-NEXT: mov w9, #-128 // =0xffffff80
60 ; CHECK-NEXT: cmn w8, #128
61 ; CHECK-NEXT: csel w0, w8, w9, gt
63 %tmp = call i8 @llvm.sadd.sat.i8(i8 %x, i8 %y);
67 define i4 @func3(i4 %x, i4 %y) nounwind {
70 ; CHECK-NEXT: lsl w9, w1, #28
71 ; CHECK-NEXT: sbfx w10, w0, #0, #4
72 ; CHECK-NEXT: mov w8, #7 // =0x7
73 ; CHECK-NEXT: add w9, w10, w9, asr #28
74 ; CHECK-NEXT: cmp w9, #7
75 ; CHECK-NEXT: csel w8, w9, w8, lt
76 ; CHECK-NEXT: mov w9, #-8 // =0xfffffff8
77 ; CHECK-NEXT: cmn w8, #8
78 ; CHECK-NEXT: csel w0, w8, w9, gt
80 %tmp = call i4 @llvm.sadd.sat.i4(i4 %x, i4 %y);
84 define <4 x i32> @vec(<4 x i32> %x, <4 x i32> %y) nounwind {
87 ; CHECK-NEXT: sqadd v0.4s, v0.4s, v1.4s
89 %tmp = call <4 x i32> @llvm.sadd.sat.v4i32(<4 x i32> %x, <4 x i32> %y);