1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=aarch64-- | FileCheck %s --check-prefixes=CHECK,CHECK-SD
3 ; RUN: llc < %s -mtriple=aarch64-- -global-isel -global-isel-abort=2 2>&1 | FileCheck %s --check-prefixes=CHECK,CHECK-GI
5 declare i4 @llvm.uadd.sat.i4(i4, i4)
6 declare i8 @llvm.uadd.sat.i8(i8, i8)
7 declare i16 @llvm.uadd.sat.i16(i16, i16)
8 declare i32 @llvm.uadd.sat.i32(i32, i32)
9 declare i64 @llvm.uadd.sat.i64(i64, i64)
11 define i32 @func32(i32 %x, i32 %y, i32 %z) nounwind {
12 ; CHECK-SD-LABEL: func32:
14 ; CHECK-SD-NEXT: mul w8, w1, w2
15 ; CHECK-SD-NEXT: adds w8, w0, w8
16 ; CHECK-SD-NEXT: csinv w0, w8, wzr, lo
19 ; CHECK-GI-LABEL: func32:
21 ; CHECK-GI-NEXT: mul w8, w1, w2
22 ; CHECK-GI-NEXT: adds w8, w0, w8
23 ; CHECK-GI-NEXT: cset w9, hs
24 ; CHECK-GI-NEXT: tst w9, #0x1
25 ; CHECK-GI-NEXT: csinv w0, w8, wzr, eq
28 %tmp = call i32 @llvm.uadd.sat.i32(i32 %x, i32 %a)
32 define i64 @func64(i64 %x, i64 %y, i64 %z) nounwind {
33 ; CHECK-SD-LABEL: func64:
35 ; CHECK-SD-NEXT: adds x8, x0, x2
36 ; CHECK-SD-NEXT: csinv x0, x8, xzr, lo
39 ; CHECK-GI-LABEL: func64:
41 ; CHECK-GI-NEXT: adds x8, x0, x2
42 ; CHECK-GI-NEXT: cset w9, hs
43 ; CHECK-GI-NEXT: tst w9, #0x1
44 ; CHECK-GI-NEXT: csinv x0, x8, xzr, eq
47 %tmp = call i64 @llvm.uadd.sat.i64(i64 %x, i64 %z)
51 define i16 @func16(i16 %x, i16 %y, i16 %z) nounwind {
52 ; CHECK-SD-LABEL: func16:
54 ; CHECK-SD-NEXT: mul w8, w1, w2
55 ; CHECK-SD-NEXT: and w9, w0, #0xffff
56 ; CHECK-SD-NEXT: add w8, w9, w8, uxth
57 ; CHECK-SD-NEXT: mov w9, #65535 // =0xffff
58 ; CHECK-SD-NEXT: cmp w8, w9
59 ; CHECK-SD-NEXT: csel w0, w8, w9, lo
62 ; CHECK-GI-LABEL: func16:
64 ; CHECK-GI-NEXT: mul w8, w1, w2
65 ; CHECK-GI-NEXT: and w8, w8, #0xffff
66 ; CHECK-GI-NEXT: add w8, w8, w0, uxth
67 ; CHECK-GI-NEXT: cmp w8, w8, uxth
68 ; CHECK-GI-NEXT: csinv w0, w8, wzr, eq
71 %tmp = call i16 @llvm.uadd.sat.i16(i16 %x, i16 %a)
75 define i8 @func8(i8 %x, i8 %y, i8 %z) nounwind {
76 ; CHECK-SD-LABEL: func8:
78 ; CHECK-SD-NEXT: mul w8, w1, w2
79 ; CHECK-SD-NEXT: and w9, w0, #0xff
80 ; CHECK-SD-NEXT: add w8, w9, w8, uxtb
81 ; CHECK-SD-NEXT: mov w9, #255 // =0xff
82 ; CHECK-SD-NEXT: cmp w8, #255
83 ; CHECK-SD-NEXT: csel w0, w8, w9, lo
86 ; CHECK-GI-LABEL: func8:
88 ; CHECK-GI-NEXT: mul w8, w1, w2
89 ; CHECK-GI-NEXT: and w8, w8, #0xff
90 ; CHECK-GI-NEXT: add w8, w8, w0, uxtb
91 ; CHECK-GI-NEXT: cmp w8, w8, uxtb
92 ; CHECK-GI-NEXT: csinv w0, w8, wzr, eq
95 %tmp = call i8 @llvm.uadd.sat.i8(i8 %x, i8 %a)
99 define i4 @func4(i4 %x, i4 %y, i4 %z) nounwind {
100 ; CHECK-SD-LABEL: func4:
101 ; CHECK-SD: // %bb.0:
102 ; CHECK-SD-NEXT: mul w8, w1, w2
103 ; CHECK-SD-NEXT: and w9, w0, #0xf
104 ; CHECK-SD-NEXT: and w8, w8, #0xf
105 ; CHECK-SD-NEXT: add w8, w9, w8
106 ; CHECK-SD-NEXT: mov w9, #15 // =0xf
107 ; CHECK-SD-NEXT: cmp w8, #15
108 ; CHECK-SD-NEXT: csel w0, w8, w9, lo
111 ; CHECK-GI-LABEL: func4:
112 ; CHECK-GI: // %bb.0:
113 ; CHECK-GI-NEXT: mul w8, w1, w2
114 ; CHECK-GI-NEXT: and w9, w0, #0xf
115 ; CHECK-GI-NEXT: mov w10, #15 // =0xf
116 ; CHECK-GI-NEXT: and w8, w8, #0xf
117 ; CHECK-GI-NEXT: add w8, w9, w8
118 ; CHECK-GI-NEXT: and w9, w8, #0xf
119 ; CHECK-GI-NEXT: cmp w8, w9
120 ; CHECK-GI-NEXT: csel w0, w10, w8, ne
123 %tmp = call i4 @llvm.uadd.sat.i4(i4 %x, i4 %a)
126 ;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line: