1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=thumbv6-none-eabi -float-abi=soft %s -o - | FileCheck %s --check-prefixes=SOFT
3 ; RUN: llc -mtriple=thumbv7-none-eabi -mattr=+vfp2 %s -o - | FileCheck %s --check-prefixes=VFP,VFP2
4 ; RUN: llc -mtriple=thumbv8.1m.main-eabi -mattr=+fullfp16,+fp64 %s -o - | FileCheck %s --check-prefixes=VFP,FP16
6 declare i32 @llvm.fptosi.sat.i32.f64(double)
7 declare i32 @llvm.fptosi.sat.i32.f32(float)
8 declare i32 @llvm.fptoui.sat.i32.f64(double)
9 declare i32 @llvm.fptoui.sat.i32.f32(float)
11 define void @test_signed_i32_f32(ptr %d, float %f) nounwind {
12 ; SOFT-LABEL: test_signed_i32_f32:
14 ; SOFT-NEXT: .save {r4, r5, r6, r7, lr}
15 ; SOFT-NEXT: push {r4, r5, r6, r7, lr}
17 ; SOFT-NEXT: sub sp, #4
18 ; SOFT-NEXT: mov r5, r1
19 ; SOFT-NEXT: mov r4, r0
20 ; SOFT-NEXT: movs r0, #207
21 ; SOFT-NEXT: lsls r1, r0, #24
22 ; SOFT-NEXT: mov r0, r5
23 ; SOFT-NEXT: bl __aeabi_fcmpge
24 ; SOFT-NEXT: mov r7, r0
25 ; SOFT-NEXT: mov r0, r5
26 ; SOFT-NEXT: bl __aeabi_f2iz
27 ; SOFT-NEXT: cmp r7, #0
28 ; SOFT-NEXT: beq .LBB0_2
30 ; SOFT-NEXT: mov r6, r0
31 ; SOFT-NEXT: b .LBB0_3
33 ; SOFT-NEXT: movs r0, #1
34 ; SOFT-NEXT: lsls r6, r0, #31
36 ; SOFT-NEXT: ldr r1, .LCPI0_0
37 ; SOFT-NEXT: mov r0, r5
38 ; SOFT-NEXT: bl __aeabi_fcmpgt
39 ; SOFT-NEXT: cmp r0, #0
40 ; SOFT-NEXT: beq .LBB0_5
42 ; SOFT-NEXT: ldr r6, .LCPI0_1
44 ; SOFT-NEXT: mov r0, r5
45 ; SOFT-NEXT: mov r1, r5
46 ; SOFT-NEXT: bl __aeabi_fcmpun
47 ; SOFT-NEXT: cmp r0, #0
48 ; SOFT-NEXT: beq .LBB0_7
50 ; SOFT-NEXT: movs r6, #0
52 ; SOFT-NEXT: str r6, [r4]
53 ; SOFT-NEXT: add sp, #4
54 ; SOFT-NEXT: pop {r4, r5, r6, r7, pc}
55 ; SOFT-NEXT: .p2align 2
57 ; SOFT-NEXT: .LCPI0_0:
58 ; SOFT-NEXT: .long 1325400063 @ 0x4effffff
59 ; SOFT-NEXT: .LCPI0_1:
60 ; SOFT-NEXT: .long 2147483647 @ 0x7fffffff
62 ; VFP-LABEL: test_signed_i32_f32:
64 ; VFP-NEXT: vmov s0, r1
65 ; VFP-NEXT: vcvt.s32.f32 s0, s0
66 ; VFP-NEXT: vstr s0, [r0]
68 %r = call i32 @llvm.fptosi.sat.i32.f32(float %f)
69 store i32 %r, ptr %d, align 4
73 define void @test_signed_i32_f64(ptr %d, double %f) nounwind {
74 ; SOFT-LABEL: test_signed_i32_f64:
76 ; SOFT-NEXT: .save {r4, r5, r6, r7, lr}
77 ; SOFT-NEXT: push {r4, r5, r6, r7, lr}
79 ; SOFT-NEXT: sub sp, #12
80 ; SOFT-NEXT: mov r5, r3
81 ; SOFT-NEXT: mov r6, r2
82 ; SOFT-NEXT: str r0, [sp, #8] @ 4-byte Spill
83 ; SOFT-NEXT: ldr r2, .LCPI1_0
84 ; SOFT-NEXT: ldr r3, .LCPI1_1
85 ; SOFT-NEXT: mov r0, r6
86 ; SOFT-NEXT: mov r1, r5
87 ; SOFT-NEXT: bl __aeabi_dcmpgt
88 ; SOFT-NEXT: str r0, [sp, #4] @ 4-byte Spill
89 ; SOFT-NEXT: movs r7, #0
90 ; SOFT-NEXT: ldr r3, .LCPI1_2
91 ; SOFT-NEXT: mov r0, r6
92 ; SOFT-NEXT: mov r1, r5
93 ; SOFT-NEXT: mov r2, r7
94 ; SOFT-NEXT: bl __aeabi_dcmpge
95 ; SOFT-NEXT: mov r4, r0
96 ; SOFT-NEXT: mov r0, r6
97 ; SOFT-NEXT: mov r1, r5
98 ; SOFT-NEXT: bl __aeabi_d2iz
99 ; SOFT-NEXT: cmp r4, #0
100 ; SOFT-NEXT: bne .LBB1_2
101 ; SOFT-NEXT: @ %bb.1:
102 ; SOFT-NEXT: movs r0, #1
103 ; SOFT-NEXT: lsls r0, r0, #31
104 ; SOFT-NEXT: .LBB1_2:
105 ; SOFT-NEXT: ldr r1, [sp, #4] @ 4-byte Reload
106 ; SOFT-NEXT: cmp r1, #0
107 ; SOFT-NEXT: bne .LBB1_4
108 ; SOFT-NEXT: @ %bb.3:
109 ; SOFT-NEXT: mov r4, r0
110 ; SOFT-NEXT: b .LBB1_5
111 ; SOFT-NEXT: .LBB1_4:
112 ; SOFT-NEXT: ldr r4, .LCPI1_3
113 ; SOFT-NEXT: .LBB1_5:
114 ; SOFT-NEXT: mov r0, r6
115 ; SOFT-NEXT: mov r1, r5
116 ; SOFT-NEXT: mov r2, r6
117 ; SOFT-NEXT: mov r3, r5
118 ; SOFT-NEXT: bl __aeabi_dcmpun
119 ; SOFT-NEXT: cmp r0, #0
120 ; SOFT-NEXT: bne .LBB1_7
121 ; SOFT-NEXT: @ %bb.6:
122 ; SOFT-NEXT: mov r7, r4
123 ; SOFT-NEXT: .LBB1_7:
124 ; SOFT-NEXT: ldr r0, [sp, #8] @ 4-byte Reload
125 ; SOFT-NEXT: str r7, [r0]
126 ; SOFT-NEXT: add sp, #12
127 ; SOFT-NEXT: pop {r4, r5, r6, r7, pc}
128 ; SOFT-NEXT: .p2align 2
129 ; SOFT-NEXT: @ %bb.8:
130 ; SOFT-NEXT: .LCPI1_0:
131 ; SOFT-NEXT: .long 4290772992 @ 0xffc00000
132 ; SOFT-NEXT: .LCPI1_1:
133 ; SOFT-NEXT: .long 1105199103 @ 0x41dfffff
134 ; SOFT-NEXT: .LCPI1_2:
135 ; SOFT-NEXT: .long 3252682752 @ 0xc1e00000
136 ; SOFT-NEXT: .LCPI1_3:
137 ; SOFT-NEXT: .long 2147483647 @ 0x7fffffff
139 ; VFP2-LABEL: test_signed_i32_f64:
141 ; VFP2-NEXT: vmov d16, r2, r3
142 ; VFP2-NEXT: vcvt.s32.f64 s0, d16
143 ; VFP2-NEXT: vstr s0, [r0]
146 ; FP16-LABEL: test_signed_i32_f64:
148 ; FP16-NEXT: vmov d0, r2, r3
149 ; FP16-NEXT: vcvt.s32.f64 s0, d0
150 ; FP16-NEXT: vstr s0, [r0]
152 %r = call i32 @llvm.fptosi.sat.i32.f64(double %f)
153 store i32 %r, ptr %d, align 4
157 define void @test_unsigned_i32_f32(ptr %d, float %f) nounwind {
158 ; SOFT-LABEL: test_unsigned_i32_f32:
160 ; SOFT-NEXT: .save {r4, r5, r6, r7, lr}
161 ; SOFT-NEXT: push {r4, r5, r6, r7, lr}
163 ; SOFT-NEXT: sub sp, #4
164 ; SOFT-NEXT: mov r7, r1
165 ; SOFT-NEXT: str r0, [sp] @ 4-byte Spill
166 ; SOFT-NEXT: ldr r1, .LCPI2_0
167 ; SOFT-NEXT: mov r0, r7
168 ; SOFT-NEXT: bl __aeabi_fcmpgt
169 ; SOFT-NEXT: mov r6, r0
170 ; SOFT-NEXT: movs r5, #0
171 ; SOFT-NEXT: mov r0, r7
172 ; SOFT-NEXT: mov r1, r5
173 ; SOFT-NEXT: bl __aeabi_fcmpge
174 ; SOFT-NEXT: mov r4, r0
175 ; SOFT-NEXT: mov r0, r7
176 ; SOFT-NEXT: bl __aeabi_f2uiz
177 ; SOFT-NEXT: cmp r4, #0
178 ; SOFT-NEXT: bne .LBB2_2
179 ; SOFT-NEXT: @ %bb.1:
180 ; SOFT-NEXT: mov r0, r4
181 ; SOFT-NEXT: .LBB2_2:
182 ; SOFT-NEXT: cmp r6, #0
183 ; SOFT-NEXT: beq .LBB2_4
184 ; SOFT-NEXT: @ %bb.3:
185 ; SOFT-NEXT: mvns r0, r5
186 ; SOFT-NEXT: .LBB2_4:
187 ; SOFT-NEXT: ldr r1, [sp] @ 4-byte Reload
188 ; SOFT-NEXT: str r0, [r1]
189 ; SOFT-NEXT: add sp, #4
190 ; SOFT-NEXT: pop {r4, r5, r6, r7, pc}
191 ; SOFT-NEXT: .p2align 2
192 ; SOFT-NEXT: @ %bb.5:
193 ; SOFT-NEXT: .LCPI2_0:
194 ; SOFT-NEXT: .long 1333788671 @ 0x4f7fffff
196 ; VFP-LABEL: test_unsigned_i32_f32:
198 ; VFP-NEXT: vmov s0, r1
199 ; VFP-NEXT: vcvt.u32.f32 s0, s0
200 ; VFP-NEXT: vstr s0, [r0]
202 %r = call i32 @llvm.fptoui.sat.i32.f32(float %f)
203 store i32 %r, ptr %d, align 4
207 define void @test_unsigned_i32_f64(ptr %d, double %f) nounwind {
208 ; SOFT-LABEL: test_unsigned_i32_f64:
210 ; SOFT-NEXT: .save {r4, r5, r6, r7, lr}
211 ; SOFT-NEXT: push {r4, r5, r6, r7, lr}
212 ; SOFT-NEXT: .pad #12
213 ; SOFT-NEXT: sub sp, #12
214 ; SOFT-NEXT: mov r5, r3
215 ; SOFT-NEXT: mov r4, r2
216 ; SOFT-NEXT: str r0, [sp, #8] @ 4-byte Spill
217 ; SOFT-NEXT: ldr r2, .LCPI3_0
218 ; SOFT-NEXT: ldr r3, .LCPI3_1
219 ; SOFT-NEXT: mov r0, r4
220 ; SOFT-NEXT: mov r1, r5
221 ; SOFT-NEXT: bl __aeabi_dcmpgt
222 ; SOFT-NEXT: str r0, [sp, #4] @ 4-byte Spill
223 ; SOFT-NEXT: movs r6, #0
224 ; SOFT-NEXT: mov r0, r4
225 ; SOFT-NEXT: mov r1, r5
226 ; SOFT-NEXT: mov r2, r6
227 ; SOFT-NEXT: mov r3, r6
228 ; SOFT-NEXT: bl __aeabi_dcmpge
229 ; SOFT-NEXT: mov r7, r0
230 ; SOFT-NEXT: mov r0, r4
231 ; SOFT-NEXT: mov r1, r5
232 ; SOFT-NEXT: bl __aeabi_d2uiz
233 ; SOFT-NEXT: cmp r7, #0
234 ; SOFT-NEXT: bne .LBB3_2
235 ; SOFT-NEXT: @ %bb.1:
236 ; SOFT-NEXT: mov r0, r7
237 ; SOFT-NEXT: .LBB3_2:
238 ; SOFT-NEXT: ldr r1, [sp, #4] @ 4-byte Reload
239 ; SOFT-NEXT: cmp r1, #0
240 ; SOFT-NEXT: beq .LBB3_4
241 ; SOFT-NEXT: @ %bb.3:
242 ; SOFT-NEXT: mvns r0, r6
243 ; SOFT-NEXT: .LBB3_4:
244 ; SOFT-NEXT: ldr r1, [sp, #8] @ 4-byte Reload
245 ; SOFT-NEXT: str r0, [r1]
246 ; SOFT-NEXT: add sp, #12
247 ; SOFT-NEXT: pop {r4, r5, r6, r7, pc}
248 ; SOFT-NEXT: .p2align 2
249 ; SOFT-NEXT: @ %bb.5:
250 ; SOFT-NEXT: .LCPI3_0:
251 ; SOFT-NEXT: .long 4292870144 @ 0xffe00000
252 ; SOFT-NEXT: .LCPI3_1:
253 ; SOFT-NEXT: .long 1106247679 @ 0x41efffff
255 ; VFP2-LABEL: test_unsigned_i32_f64:
257 ; VFP2-NEXT: vmov d16, r2, r3
258 ; VFP2-NEXT: vcvt.u32.f64 s0, d16
259 ; VFP2-NEXT: vstr s0, [r0]
262 ; FP16-LABEL: test_unsigned_i32_f64:
264 ; FP16-NEXT: vmov d0, r2, r3
265 ; FP16-NEXT: vcvt.u32.f64 s0, d0
266 ; FP16-NEXT: vstr s0, [r0]
268 %r = call i32 @llvm.fptoui.sat.i32.f64(double %f)
269 store i32 %r, ptr %d, align 4