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 @func(i32 %x, i32 %y) nounwind {
14 ; CHECK-T1-LABEL: func:
16 ; CHECK-T1-NEXT: adds r0, r0, r1
17 ; CHECK-T1-NEXT: blo .LBB0_2
18 ; CHECK-T1-NEXT: @ %bb.1:
19 ; CHECK-T1-NEXT: movs r0, #0
20 ; CHECK-T1-NEXT: mvns r0, r0
21 ; CHECK-T1-NEXT: .LBB0_2:
22 ; CHECK-T1-NEXT: bx lr
24 ; CHECK-T2-LABEL: func:
26 ; CHECK-T2-NEXT: adds r0, r0, r1
27 ; CHECK-T2-NEXT: it hs
28 ; CHECK-T2-NEXT: movhs.w r0, #-1
29 ; CHECK-T2-NEXT: bx lr
31 ; CHECK-ARM-LABEL: func:
33 ; CHECK-ARM-NEXT: adds r0, r0, r1
34 ; CHECK-ARM-NEXT: mvnhs r0, #0
35 ; CHECK-ARM-NEXT: bx lr
36 %tmp = call i32 @llvm.uadd.sat.i32(i32 %x, i32 %y)
40 define i64 @func2(i64 %x, i64 %y) nounwind {
41 ; CHECK-T1-LABEL: func2:
43 ; CHECK-T1-NEXT: .save {r4, r5, r7, lr}
44 ; CHECK-T1-NEXT: push {r4, r5, r7, lr}
45 ; CHECK-T1-NEXT: movs r5, #0
46 ; CHECK-T1-NEXT: adds r4, r0, r2
47 ; CHECK-T1-NEXT: adcs r1, r3
48 ; CHECK-T1-NEXT: mov r3, r5
49 ; CHECK-T1-NEXT: adcs r3, r5
50 ; CHECK-T1-NEXT: mvns r2, r5
51 ; CHECK-T1-NEXT: cmp r3, #0
52 ; CHECK-T1-NEXT: mov r0, r2
53 ; CHECK-T1-NEXT: beq .LBB1_3
54 ; CHECK-T1-NEXT: @ %bb.1:
55 ; CHECK-T1-NEXT: cmp r3, #0
56 ; CHECK-T1-NEXT: beq .LBB1_4
57 ; CHECK-T1-NEXT: .LBB1_2:
58 ; CHECK-T1-NEXT: mov r1, r2
59 ; CHECK-T1-NEXT: pop {r4, r5, r7, pc}
60 ; CHECK-T1-NEXT: .LBB1_3:
61 ; CHECK-T1-NEXT: mov r0, r4
62 ; CHECK-T1-NEXT: cmp r3, #0
63 ; CHECK-T1-NEXT: bne .LBB1_2
64 ; CHECK-T1-NEXT: .LBB1_4:
65 ; CHECK-T1-NEXT: mov r2, r1
66 ; CHECK-T1-NEXT: mov r1, r2
67 ; CHECK-T1-NEXT: pop {r4, r5, r7, pc}
69 ; CHECK-T2-LABEL: func2:
71 ; CHECK-T2-NEXT: adds r0, r0, r2
72 ; CHECK-T2-NEXT: mov.w r12, #0
73 ; CHECK-T2-NEXT: adcs r1, r3
74 ; CHECK-T2-NEXT: adcs r2, r12, #0
75 ; CHECK-T2-NEXT: itt ne
76 ; CHECK-T2-NEXT: movne.w r0, #-1
77 ; CHECK-T2-NEXT: movne.w r1, #-1
78 ; CHECK-T2-NEXT: bx lr
80 ; CHECK-ARM-LABEL: func2:
82 ; CHECK-ARM-NEXT: adds r0, r0, r2
83 ; CHECK-ARM-NEXT: mov r12, #0
84 ; CHECK-ARM-NEXT: adcs r1, r1, r3
85 ; CHECK-ARM-NEXT: adcs r2, r12, #0
86 ; CHECK-ARM-NEXT: mvnne r0, #0
87 ; CHECK-ARM-NEXT: mvnne r1, #0
88 ; CHECK-ARM-NEXT: bx lr
89 %tmp = call i64 @llvm.uadd.sat.i64(i64 %x, i64 %y)
93 define i16 @func16(i16 %x, i16 %y) nounwind {
94 ; CHECK-T1-LABEL: func16:
96 ; CHECK-T1-NEXT: lsls r1, r1, #16
97 ; CHECK-T1-NEXT: lsls r0, r0, #16
98 ; CHECK-T1-NEXT: adds r0, r0, r1
99 ; CHECK-T1-NEXT: blo .LBB2_2
100 ; CHECK-T1-NEXT: @ %bb.1:
101 ; CHECK-T1-NEXT: movs r0, #0
102 ; CHECK-T1-NEXT: mvns r0, r0
103 ; CHECK-T1-NEXT: .LBB2_2:
104 ; CHECK-T1-NEXT: lsrs r0, r0, #16
105 ; CHECK-T1-NEXT: bx lr
107 ; CHECK-T2-LABEL: func16:
109 ; CHECK-T2-NEXT: lsls r2, r0, #16
110 ; CHECK-T2-NEXT: add.w r1, r2, r1, lsl #16
111 ; CHECK-T2-NEXT: cmp.w r1, r0, lsl #16
112 ; CHECK-T2-NEXT: it lo
113 ; CHECK-T2-NEXT: movlo.w r1, #-1
114 ; CHECK-T2-NEXT: lsrs r0, r1, #16
115 ; CHECK-T2-NEXT: bx lr
117 ; CHECK-ARM-LABEL: func16:
118 ; CHECK-ARM: @ %bb.0:
119 ; CHECK-ARM-NEXT: lsl r2, r0, #16
120 ; CHECK-ARM-NEXT: add r1, r2, r1, lsl #16
121 ; CHECK-ARM-NEXT: cmp r1, r0, lsl #16
122 ; CHECK-ARM-NEXT: mvnlo r1, #0
123 ; CHECK-ARM-NEXT: lsr r0, r1, #16
124 ; CHECK-ARM-NEXT: bx lr
125 %tmp = call i16 @llvm.uadd.sat.i16(i16 %x, i16 %y)
129 define i8 @func8(i8 %x, i8 %y) nounwind {
130 ; CHECK-T1-LABEL: func8:
132 ; CHECK-T1-NEXT: lsls r1, r1, #24
133 ; CHECK-T1-NEXT: lsls r0, r0, #24
134 ; CHECK-T1-NEXT: adds r0, r0, r1
135 ; CHECK-T1-NEXT: blo .LBB3_2
136 ; CHECK-T1-NEXT: @ %bb.1:
137 ; CHECK-T1-NEXT: movs r0, #0
138 ; CHECK-T1-NEXT: mvns r0, r0
139 ; CHECK-T1-NEXT: .LBB3_2:
140 ; CHECK-T1-NEXT: lsrs r0, r0, #24
141 ; CHECK-T1-NEXT: bx lr
143 ; CHECK-T2-LABEL: func8:
145 ; CHECK-T2-NEXT: lsls r2, r0, #24
146 ; CHECK-T2-NEXT: add.w r1, r2, r1, lsl #24
147 ; CHECK-T2-NEXT: cmp.w r1, r0, lsl #24
148 ; CHECK-T2-NEXT: it lo
149 ; CHECK-T2-NEXT: movlo.w r1, #-1
150 ; CHECK-T2-NEXT: lsrs r0, r1, #24
151 ; CHECK-T2-NEXT: bx lr
153 ; CHECK-ARM-LABEL: func8:
154 ; CHECK-ARM: @ %bb.0:
155 ; CHECK-ARM-NEXT: lsl r2, r0, #24
156 ; CHECK-ARM-NEXT: add r1, r2, r1, lsl #24
157 ; CHECK-ARM-NEXT: cmp r1, r0, lsl #24
158 ; CHECK-ARM-NEXT: mvnlo r1, #0
159 ; CHECK-ARM-NEXT: lsr r0, r1, #24
160 ; CHECK-ARM-NEXT: bx lr
161 %tmp = call i8 @llvm.uadd.sat.i8(i8 %x, i8 %y)
165 define i4 @func3(i4 %x, i4 %y) nounwind {
166 ; CHECK-T1-LABEL: func3:
168 ; CHECK-T1-NEXT: lsls r1, r1, #28
169 ; CHECK-T1-NEXT: lsls r0, r0, #28
170 ; CHECK-T1-NEXT: adds r0, r0, r1
171 ; CHECK-T1-NEXT: blo .LBB4_2
172 ; CHECK-T1-NEXT: @ %bb.1:
173 ; CHECK-T1-NEXT: movs r0, #0
174 ; CHECK-T1-NEXT: mvns r0, r0
175 ; CHECK-T1-NEXT: .LBB4_2:
176 ; CHECK-T1-NEXT: lsrs r0, r0, #28
177 ; CHECK-T1-NEXT: bx lr
179 ; CHECK-T2-LABEL: func3:
181 ; CHECK-T2-NEXT: lsls r2, r0, #28
182 ; CHECK-T2-NEXT: add.w r1, r2, r1, lsl #28
183 ; CHECK-T2-NEXT: cmp.w r1, r0, lsl #28
184 ; CHECK-T2-NEXT: it lo
185 ; CHECK-T2-NEXT: movlo.w r1, #-1
186 ; CHECK-T2-NEXT: lsrs r0, r1, #28
187 ; CHECK-T2-NEXT: bx lr
189 ; CHECK-ARM-LABEL: func3:
190 ; CHECK-ARM: @ %bb.0:
191 ; CHECK-ARM-NEXT: lsl r2, r0, #28
192 ; CHECK-ARM-NEXT: add r1, r2, r1, lsl #28
193 ; CHECK-ARM-NEXT: cmp r1, r0, lsl #28
194 ; CHECK-ARM-NEXT: mvnlo r1, #0
195 ; CHECK-ARM-NEXT: lsr r0, r1, #28
196 ; CHECK-ARM-NEXT: bx lr
197 %tmp = call i4 @llvm.uadd.sat.i4(i4 %x, i4 %y)