1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=thumbv6m-none-eabi | FileCheck %s --check-prefix=CHECK-T1
3 ; RUN: llc < %s -mtriple=thumbv7m-none-eabi | FileCheck %s --check-prefix=CHECK-T2 --check-prefix=CHECK-T2NODSP
4 ; RUN: llc < %s -mtriple=thumbv7em-none-eabi | FileCheck %s --check-prefix=CHECK-T2 --check-prefix=CHECK-T2DSP
5 ; RUN: llc < %s -mtriple=armv8a-none-eabi | FileCheck %s --check-prefix=CHECK-ARM
7 declare i4 @llvm.uadd.sat.i4(i4, i4)
8 declare i8 @llvm.uadd.sat.i8(i8, i8)
9 declare i16 @llvm.uadd.sat.i16(i16, i16)
10 declare i32 @llvm.uadd.sat.i32(i32, i32)
11 declare i64 @llvm.uadd.sat.i64(i64, i64)
13 define i32 @func32(i32 %x, i32 %y, i32 %z) nounwind {
14 ; CHECK-T1-LABEL: func32:
16 ; CHECK-T1-NEXT: muls r1, r2, r1
17 ; CHECK-T1-NEXT: adds r0, r0, r1
18 ; CHECK-T1-NEXT: blo .LBB0_2
19 ; CHECK-T1-NEXT: @ %bb.1:
20 ; CHECK-T1-NEXT: movs r0, #0
21 ; CHECK-T1-NEXT: mvns r0, r0
22 ; CHECK-T1-NEXT: .LBB0_2:
23 ; CHECK-T1-NEXT: bx lr
25 ; CHECK-T2-LABEL: func32:
27 ; CHECK-T2-NEXT: muls r1, r2, r1
28 ; CHECK-T2-NEXT: adds r0, r0, r1
29 ; CHECK-T2-NEXT: it hs
30 ; CHECK-T2-NEXT: movhs.w r0, #-1
31 ; CHECK-T2-NEXT: bx lr
33 ; CHECK-ARM-LABEL: func32:
35 ; CHECK-ARM-NEXT: mul r1, r1, r2
36 ; CHECK-ARM-NEXT: adds r0, r0, r1
37 ; CHECK-ARM-NEXT: mvnhs r0, #0
38 ; CHECK-ARM-NEXT: bx lr
40 %tmp = call i32 @llvm.uadd.sat.i32(i32 %x, i32 %a)
44 define i64 @func64(i64 %x, i64 %y, i64 %z) nounwind {
45 ; CHECK-T1-LABEL: func64:
47 ; CHECK-T1-NEXT: .save {r4, r5, r7, lr}
48 ; CHECK-T1-NEXT: push {r4, r5, r7, lr}
49 ; CHECK-T1-NEXT: movs r5, #0
50 ; CHECK-T1-NEXT: ldr r2, [sp, #20]
51 ; CHECK-T1-NEXT: ldr r3, [sp, #16]
52 ; CHECK-T1-NEXT: adds r3, r0, r3
53 ; CHECK-T1-NEXT: adcs r2, r1
54 ; CHECK-T1-NEXT: mov r4, r5
55 ; CHECK-T1-NEXT: adcs r4, r5
56 ; CHECK-T1-NEXT: mvns r1, r5
57 ; CHECK-T1-NEXT: cmp r4, #0
58 ; CHECK-T1-NEXT: mov r0, r1
59 ; CHECK-T1-NEXT: beq .LBB1_3
60 ; CHECK-T1-NEXT: @ %bb.1:
61 ; CHECK-T1-NEXT: cmp r4, #0
62 ; CHECK-T1-NEXT: beq .LBB1_4
63 ; CHECK-T1-NEXT: .LBB1_2:
64 ; CHECK-T1-NEXT: pop {r4, r5, r7, pc}
65 ; CHECK-T1-NEXT: .LBB1_3:
66 ; CHECK-T1-NEXT: mov r0, r3
67 ; CHECK-T1-NEXT: cmp r4, #0
68 ; CHECK-T1-NEXT: bne .LBB1_2
69 ; CHECK-T1-NEXT: .LBB1_4:
70 ; CHECK-T1-NEXT: mov r1, r2
71 ; CHECK-T1-NEXT: pop {r4, r5, r7, pc}
73 ; CHECK-T2-LABEL: func64:
75 ; CHECK-T2-NEXT: ldrd r2, r3, [sp]
76 ; CHECK-T2-NEXT: mov.w r12, #0
77 ; CHECK-T2-NEXT: adds r0, r0, r2
78 ; CHECK-T2-NEXT: adcs r1, r3
79 ; CHECK-T2-NEXT: adcs r2, r12, #0
80 ; CHECK-T2-NEXT: itt ne
81 ; CHECK-T2-NEXT: movne.w r0, #-1
82 ; CHECK-T2-NEXT: movne.w r1, #-1
83 ; CHECK-T2-NEXT: bx lr
85 ; CHECK-ARM-LABEL: func64:
87 ; CHECK-ARM-NEXT: ldr r2, [sp]
88 ; CHECK-ARM-NEXT: mov r12, #0
89 ; CHECK-ARM-NEXT: ldr r3, [sp, #4]
90 ; CHECK-ARM-NEXT: adds r0, r0, r2
91 ; CHECK-ARM-NEXT: adcs r1, r1, r3
92 ; CHECK-ARM-NEXT: adcs r2, r12, #0
93 ; CHECK-ARM-NEXT: mvnne r0, #0
94 ; CHECK-ARM-NEXT: mvnne r1, #0
95 ; CHECK-ARM-NEXT: bx lr
97 %tmp = call i64 @llvm.uadd.sat.i64(i64 %x, i64 %z)
101 define zeroext i16 @func16(i16 zeroext %x, i16 zeroext %y, i16 zeroext %z) nounwind {
102 ; CHECK-T1-LABEL: func16:
104 ; CHECK-T1-NEXT: muls r1, r2, r1
105 ; CHECK-T1-NEXT: uxth r1, r1
106 ; CHECK-T1-NEXT: adds r0, r0, r1
107 ; CHECK-T1-NEXT: ldr r1, .LCPI2_0
108 ; CHECK-T1-NEXT: cmp r0, r1
109 ; CHECK-T1-NEXT: blo .LBB2_2
110 ; CHECK-T1-NEXT: @ %bb.1:
111 ; CHECK-T1-NEXT: mov r0, r1
112 ; CHECK-T1-NEXT: .LBB2_2:
113 ; CHECK-T1-NEXT: bx lr
114 ; CHECK-T1-NEXT: .p2align 2
115 ; CHECK-T1-NEXT: @ %bb.3:
116 ; CHECK-T1-NEXT: .LCPI2_0:
117 ; CHECK-T1-NEXT: .long 65535 @ 0xffff
119 ; CHECK-T2NODSP-LABEL: func16:
120 ; CHECK-T2NODSP: @ %bb.0:
121 ; CHECK-T2NODSP-NEXT: muls r1, r2, r1
122 ; CHECK-T2NODSP-NEXT: uxth r1, r1
123 ; CHECK-T2NODSP-NEXT: add r1, r0
124 ; CHECK-T2NODSP-NEXT: movw r0, #65535
125 ; CHECK-T2NODSP-NEXT: cmp r1, r0
126 ; CHECK-T2NODSP-NEXT: it lo
127 ; CHECK-T2NODSP-NEXT: movlo r0, r1
128 ; CHECK-T2NODSP-NEXT: bx lr
130 ; CHECK-T2DSP-LABEL: func16:
131 ; CHECK-T2DSP: @ %bb.0:
132 ; CHECK-T2DSP-NEXT: muls r1, r2, r1
133 ; CHECK-T2DSP-NEXT: uxtah r1, r0, r1
134 ; CHECK-T2DSP-NEXT: movw r0, #65535
135 ; CHECK-T2DSP-NEXT: cmp r1, r0
136 ; CHECK-T2DSP-NEXT: it lo
137 ; CHECK-T2DSP-NEXT: movlo r0, r1
138 ; CHECK-T2DSP-NEXT: bx lr
140 ; CHECK-ARM-LABEL: func16:
141 ; CHECK-ARM: @ %bb.0:
142 ; CHECK-ARM-NEXT: mul r1, r1, r2
143 ; CHECK-ARM-NEXT: uxtah r1, r0, r1
144 ; CHECK-ARM-NEXT: movw r0, #65535
145 ; CHECK-ARM-NEXT: cmp r1, r0
146 ; CHECK-ARM-NEXT: movlo r0, r1
147 ; CHECK-ARM-NEXT: bx lr
149 %tmp = call i16 @llvm.uadd.sat.i16(i16 %x, i16 %a)
153 define zeroext i8 @func8(i8 zeroext %x, i8 zeroext %y, i8 zeroext %z) nounwind {
154 ; CHECK-T1-LABEL: func8:
156 ; CHECK-T1-NEXT: muls r1, r2, r1
157 ; CHECK-T1-NEXT: uxtb r1, r1
158 ; CHECK-T1-NEXT: adds r0, r0, r1
159 ; CHECK-T1-NEXT: cmp r0, #255
160 ; CHECK-T1-NEXT: blo .LBB3_2
161 ; CHECK-T1-NEXT: @ %bb.1:
162 ; CHECK-T1-NEXT: movs r0, #255
163 ; CHECK-T1-NEXT: .LBB3_2:
164 ; CHECK-T1-NEXT: bx lr
166 ; CHECK-T2NODSP-LABEL: func8:
167 ; CHECK-T2NODSP: @ %bb.0:
168 ; CHECK-T2NODSP-NEXT: muls r1, r2, r1
169 ; CHECK-T2NODSP-NEXT: uxtb r1, r1
170 ; CHECK-T2NODSP-NEXT: add r0, r1
171 ; CHECK-T2NODSP-NEXT: cmp r0, #255
172 ; CHECK-T2NODSP-NEXT: it hs
173 ; CHECK-T2NODSP-NEXT: movhs r0, #255
174 ; CHECK-T2NODSP-NEXT: bx lr
176 ; CHECK-T2DSP-LABEL: func8:
177 ; CHECK-T2DSP: @ %bb.0:
178 ; CHECK-T2DSP-NEXT: muls r1, r2, r1
179 ; CHECK-T2DSP-NEXT: uxtab r0, r0, r1
180 ; CHECK-T2DSP-NEXT: cmp r0, #255
181 ; CHECK-T2DSP-NEXT: it hs
182 ; CHECK-T2DSP-NEXT: movhs r0, #255
183 ; CHECK-T2DSP-NEXT: bx lr
185 ; CHECK-ARM-LABEL: func8:
186 ; CHECK-ARM: @ %bb.0:
187 ; CHECK-ARM-NEXT: smulbb r1, r1, r2
188 ; CHECK-ARM-NEXT: uxtab r0, r0, r1
189 ; CHECK-ARM-NEXT: cmp r0, #255
190 ; CHECK-ARM-NEXT: movhs r0, #255
191 ; CHECK-ARM-NEXT: bx lr
193 %tmp = call i8 @llvm.uadd.sat.i8(i8 %x, i8 %a)
197 define zeroext i4 @func4(i4 zeroext %x, i4 zeroext %y, i4 zeroext %z) nounwind {
198 ; CHECK-T1-LABEL: func4:
200 ; CHECK-T1-NEXT: muls r1, r2, r1
201 ; CHECK-T1-NEXT: movs r2, #15
202 ; CHECK-T1-NEXT: ands r1, r2
203 ; CHECK-T1-NEXT: adds r0, r0, r1
204 ; CHECK-T1-NEXT: cmp r0, #15
205 ; CHECK-T1-NEXT: blo .LBB4_2
206 ; CHECK-T1-NEXT: @ %bb.1:
207 ; CHECK-T1-NEXT: mov r0, r2
208 ; CHECK-T1-NEXT: .LBB4_2:
209 ; CHECK-T1-NEXT: bx lr
211 ; CHECK-T2-LABEL: func4:
213 ; CHECK-T2-NEXT: muls r1, r2, r1
214 ; CHECK-T2-NEXT: and r1, r1, #15
215 ; CHECK-T2-NEXT: add r0, r1
216 ; CHECK-T2-NEXT: cmp r0, #15
217 ; CHECK-T2-NEXT: it hs
218 ; CHECK-T2-NEXT: movhs r0, #15
219 ; CHECK-T2-NEXT: bx lr
221 ; CHECK-ARM-LABEL: func4:
222 ; CHECK-ARM: @ %bb.0:
223 ; CHECK-ARM-NEXT: smulbb r1, r1, r2
224 ; CHECK-ARM-NEXT: and r1, r1, #15
225 ; CHECK-ARM-NEXT: add r0, r0, r1
226 ; CHECK-ARM-NEXT: cmp r0, #15
227 ; CHECK-ARM-NEXT: movhs r0, #15
228 ; CHECK-ARM-NEXT: bx lr
230 %tmp = call i4 @llvm.uadd.sat.i4(i4 %x, i4 %a)