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)
10 define i32 @func32(i32 %x, i32 %y, i32 %z) nounwind {
11 ; CHECK-LABEL: func32:
13 ; CHECK-NEXT: mul w8, w1, w2
14 ; CHECK-NEXT: adds w8, w0, w8
15 ; CHECK-NEXT: asr w9, w8, #31
16 ; CHECK-NEXT: eor w9, w9, #0x80000000
17 ; CHECK-NEXT: csel w0, w9, w8, vs
20 %tmp = call i32 @llvm.sadd.sat.i32(i32 %x, i32 %a)
24 define i64 @func64(i64 %x, i64 %y, i64 %z) nounwind {
25 ; CHECK-LABEL: func64:
27 ; CHECK-NEXT: adds x8, x0, x2
28 ; CHECK-NEXT: asr x9, x8, #63
29 ; CHECK-NEXT: eor x9, x9, #0x8000000000000000
30 ; CHECK-NEXT: csel x0, x9, x8, vs
33 %tmp = call i64 @llvm.sadd.sat.i64(i64 %x, i64 %z)
37 define i16 @func16(i16 %x, i16 %y, i16 %z) nounwind {
38 ; CHECK-LABEL: func16:
40 ; CHECK-NEXT: mul w8, w1, w2
41 ; CHECK-NEXT: sxth w9, w0
42 ; CHECK-NEXT: add w8, w9, w8, sxth
43 ; CHECK-NEXT: mov w9, #32767 // =0x7fff
44 ; CHECK-NEXT: cmp w8, w9
45 ; CHECK-NEXT: csel w8, w8, w9, lt
46 ; CHECK-NEXT: mov w9, #-32768 // =0xffff8000
47 ; CHECK-NEXT: cmn w8, #8, lsl #12 // =32768
48 ; CHECK-NEXT: csel w0, w8, w9, gt
51 %tmp = call i16 @llvm.sadd.sat.i16(i16 %x, i16 %a)
55 define i8 @func8(i8 %x, i8 %y, i8 %z) nounwind {
58 ; CHECK-NEXT: mul w8, w1, w2
59 ; CHECK-NEXT: sxtb w9, w0
60 ; CHECK-NEXT: add w8, w9, w8, sxtb
61 ; CHECK-NEXT: mov w9, #127 // =0x7f
62 ; CHECK-NEXT: cmp w8, #127
63 ; CHECK-NEXT: csel w8, w8, w9, lt
64 ; CHECK-NEXT: mov w9, #-128 // =0xffffff80
65 ; CHECK-NEXT: cmn w8, #128
66 ; CHECK-NEXT: csel w0, w8, w9, gt
69 %tmp = call i8 @llvm.sadd.sat.i8(i8 %x, i8 %a)
73 define i4 @func4(i4 %x, i4 %y, i4 %z) nounwind {
76 ; CHECK-NEXT: mul w8, w1, w2
77 ; CHECK-NEXT: sbfx w9, w0, #0, #4
78 ; CHECK-NEXT: lsl w8, w8, #28
79 ; CHECK-NEXT: add w8, w9, w8, asr #28
80 ; CHECK-NEXT: mov w9, #7 // =0x7
81 ; CHECK-NEXT: cmp w8, #7
82 ; CHECK-NEXT: csel w8, w8, w9, lt
83 ; CHECK-NEXT: mov w9, #-8 // =0xfffffff8
84 ; CHECK-NEXT: cmn w8, #8
85 ; CHECK-NEXT: csel w0, w8, w9, gt
88 %tmp = call i4 @llvm.sadd.sat.i4(i4 %x, i4 %a)