1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 4
2 ; RUN: llc < %s -mtriple=i686-unknown-unknown | FileCheck %s --check-prefix=X86
3 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s --check-prefix=X64
5 declare void @use.i1(i1)
6 declare void @use.i32(i32)
7 define i32 @sitofp_signbit_only(i32 %i_in) nounwind {
8 ; X86-LABEL: sitofp_signbit_only:
10 ; X86-NEXT: subl $8, %esp
11 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
12 ; X86-NEXT: movl %eax, (%esp)
13 ; X86-NEXT: fildl (%esp)
14 ; X86-NEXT: fstps {{[0-9]+}}(%esp)
15 ; X86-NEXT: movl $-2147483648, %eax # imm = 0x80000000
16 ; X86-NEXT: andl {{[0-9]+}}(%esp), %eax
17 ; X86-NEXT: addl $8, %esp
20 ; X64-LABEL: sitofp_signbit_only:
22 ; X64-NEXT: cvtsi2ss %edi, %xmm0
23 ; X64-NEXT: movmskps %xmm0, %eax
24 ; X64-NEXT: shll $31, %eax
26 %f = sitofp i32 %i_in to float
27 %i = bitcast float %f to i32
28 %r = and i32 %i, 2147483648
32 define i32 @sitofp_signbit_only_okay_width(i16 %i_in) nounwind {
33 ; X86-LABEL: sitofp_signbit_only_okay_width:
35 ; X86-NEXT: subl $8, %esp
36 ; X86-NEXT: movzwl {{[0-9]+}}(%esp), %eax
37 ; X86-NEXT: movw %ax, {{[0-9]+}}(%esp)
38 ; X86-NEXT: filds {{[0-9]+}}(%esp)
39 ; X86-NEXT: fstps {{[0-9]+}}(%esp)
40 ; X86-NEXT: movl $-2147483648, %eax # imm = 0x80000000
41 ; X86-NEXT: andl {{[0-9]+}}(%esp), %eax
42 ; X86-NEXT: addl $8, %esp
45 ; X64-LABEL: sitofp_signbit_only_okay_width:
47 ; X64-NEXT: movswl %di, %eax
48 ; X64-NEXT: cvtsi2ss %eax, %xmm0
49 ; X64-NEXT: movmskps %xmm0, %eax
50 ; X64-NEXT: shll $31, %eax
52 %f = sitofp i16 %i_in to float
53 %i = bitcast float %f to i32
54 %r = and i32 %i, 2147483648
58 define i32 @sitofp_signbit_only_fail_bad_width1(i64 %i_in) nounwind {
59 ; X86-LABEL: sitofp_signbit_only_fail_bad_width1:
61 ; X86-NEXT: pushl %eax
62 ; X86-NEXT: fildll {{[0-9]+}}(%esp)
63 ; X86-NEXT: fstps (%esp)
64 ; X86-NEXT: movl $-2147483648, %eax # imm = 0x80000000
65 ; X86-NEXT: andl (%esp), %eax
69 ; X64-LABEL: sitofp_signbit_only_fail_bad_width1:
71 ; X64-NEXT: cvtsi2ss %rdi, %xmm0
72 ; X64-NEXT: movmskps %xmm0, %eax
73 ; X64-NEXT: shll $31, %eax
75 %f = sitofp i64 %i_in to float
76 %i = bitcast float %f to i32
77 %r = and i32 %i, 2147483648
81 define <2 x i16> @sitofp_signbit_only_fail_bad_width2(i32 %i_in) nounwind {
82 ; X86-LABEL: sitofp_signbit_only_fail_bad_width2:
84 ; X86-NEXT: subl $8, %esp
85 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
86 ; X86-NEXT: movl %eax, (%esp)
87 ; X86-NEXT: fildl (%esp)
88 ; X86-NEXT: fstps {{[0-9]+}}(%esp)
89 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
90 ; X86-NEXT: movl %eax, %edx
91 ; X86-NEXT: shrl $16, %edx
92 ; X86-NEXT: andl $32768, %eax # imm = 0x8000
93 ; X86-NEXT: andl $32768, %edx # imm = 0x8000
94 ; X86-NEXT: # kill: def $ax killed $ax killed $eax
95 ; X86-NEXT: # kill: def $dx killed $dx killed $edx
96 ; X86-NEXT: addl $8, %esp
99 ; X64-LABEL: sitofp_signbit_only_fail_bad_width2:
101 ; X64-NEXT: cvtsi2ss %edi, %xmm0
102 ; X64-NEXT: andps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
104 %f = sitofp i32 %i_in to float
105 %i2xi16 = bitcast float %f to <2 x i16>
106 %r = and <2 x i16> %i2xi16, <i16 32768, i16 32768>
110 define i32 @sitofp_many_bits_fail(i32 %i_in) nounwind {
111 ; X86-LABEL: sitofp_many_bits_fail:
113 ; X86-NEXT: subl $8, %esp
114 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
115 ; X86-NEXT: movl %eax, (%esp)
116 ; X86-NEXT: fildl (%esp)
117 ; X86-NEXT: fstps {{[0-9]+}}(%esp)
118 ; X86-NEXT: movl $-2147483647, %eax # imm = 0x80000001
119 ; X86-NEXT: andl {{[0-9]+}}(%esp), %eax
120 ; X86-NEXT: addl $8, %esp
123 ; X64-LABEL: sitofp_many_bits_fail:
125 ; X64-NEXT: cvtsi2ss %edi, %xmm0
126 ; X64-NEXT: movd %xmm0, %eax
127 ; X64-NEXT: andl $-2147483647, %eax # imm = 0x80000001
129 %f = sitofp i32 %i_in to float
130 %i = bitcast float %f to i32
131 %r = and i32 %i, 2147483649
135 define i32 @sitofp_multiuse_fail(i32 %i_in) nounwind {
136 ; X86-LABEL: sitofp_multiuse_fail:
138 ; X86-NEXT: subl $12, %esp
139 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
140 ; X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
141 ; X86-NEXT: fildl {{[0-9]+}}(%esp)
142 ; X86-NEXT: fsts {{[0-9]+}}(%esp)
143 ; X86-NEXT: fstps (%esp)
144 ; X86-NEXT: calll use.i32@PLT
145 ; X86-NEXT: movl $-2147483648, %eax # imm = 0x80000000
146 ; X86-NEXT: andl {{[0-9]+}}(%esp), %eax
147 ; X86-NEXT: addl $12, %esp
150 ; X64-LABEL: sitofp_multiuse_fail:
152 ; X64-NEXT: pushq %rbx
153 ; X64-NEXT: cvtsi2ss %edi, %xmm0
154 ; X64-NEXT: movd %xmm0, %ebx
155 ; X64-NEXT: movl %ebx, %edi
156 ; X64-NEXT: callq use.i32@PLT
157 ; X64-NEXT: andl $-2147483648, %ebx # imm = 0x80000000
158 ; X64-NEXT: movl %ebx, %eax
159 ; X64-NEXT: popq %rbx
161 %f = sitofp i32 %i_in to float
162 %i = bitcast float %f to i32
163 call void @use.i32(i32 %i)
164 %r = and i32 %i, 2147483648
168 define i32 @sitofp_multiuse_okay(i32 %i_in) nounwind {
169 ; X86-LABEL: sitofp_multiuse_okay:
171 ; X86-NEXT: subl $12, %esp
172 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
173 ; X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
174 ; X86-NEXT: fildl {{[0-9]+}}(%esp)
175 ; X86-NEXT: fsts {{[0-9]+}}(%esp)
176 ; X86-NEXT: fstps (%esp)
177 ; X86-NEXT: calll use.i1@PLT
178 ; X86-NEXT: movl $-2147483648, %eax # imm = 0x80000000
179 ; X86-NEXT: andl {{[0-9]+}}(%esp), %eax
180 ; X86-NEXT: addl $12, %esp
183 ; X64-LABEL: sitofp_multiuse_okay:
185 ; X64-NEXT: pushq %rbx
186 ; X64-NEXT: cvtsi2ss %edi, %xmm0
187 ; X64-NEXT: movd %xmm0, %ebx
188 ; X64-NEXT: movl %ebx, %edi
189 ; X64-NEXT: callq use.i1@PLT
190 ; X64-NEXT: andl $-2147483648, %ebx # imm = 0x80000000
191 ; X64-NEXT: movl %ebx, %eax
192 ; X64-NEXT: popq %rbx
194 %f = sitofp i32 %i_in to float
195 %i = bitcast float %f to i32
196 %cmp = icmp slt i32 %i, 0
197 call void @use.i1(i32 %i)
198 %r = and i32 %i, 2147483648
202 define i32 @uitofp_signbit_only(i32 %i_in) nounwind {
203 ; X86-LABEL: uitofp_signbit_only:
205 ; X86-NEXT: xorl %eax, %eax
208 ; X64-LABEL: uitofp_signbit_only:
210 ; X64-NEXT: xorl %eax, %eax
212 %f = uitofp i32 %i_in to float
213 %i = bitcast float %f to i32
214 %r = and i32 %i, 2147483648
218 define i32 @uitofp_signbit_only_okay_width(i16 %i_in) nounwind {
219 ; X86-LABEL: uitofp_signbit_only_okay_width:
221 ; X86-NEXT: xorl %eax, %eax
224 ; X64-LABEL: uitofp_signbit_only_okay_width:
226 ; X64-NEXT: xorl %eax, %eax
228 %f = uitofp i16 %i_in to float
229 %i = bitcast float %f to i32
230 %r = and i32 %i, 2147483648
234 define i32 @uitofp_signbit_only_okay_width1(i64 %i_in) nounwind {
235 ; X86-LABEL: uitofp_signbit_only_okay_width1:
237 ; X86-NEXT: xorl %eax, %eax
240 ; X64-LABEL: uitofp_signbit_only_okay_width1:
242 ; X64-NEXT: xorl %eax, %eax
244 %f = uitofp i64 %i_in to float
245 %i = bitcast float %f to i32
246 %r = and i32 %i, 2147483648
250 define <2 x i16> @uitofp_signbit_only_fail_bad_width2(i32 %i_in) nounwind {
251 ; X86-LABEL: uitofp_signbit_only_fail_bad_width2:
253 ; X86-NEXT: pushl %ebp
254 ; X86-NEXT: movl %esp, %ebp
255 ; X86-NEXT: andl $-8, %esp
256 ; X86-NEXT: subl $16, %esp
257 ; X86-NEXT: movl 8(%ebp), %eax
258 ; X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
259 ; X86-NEXT: movl $0, {{[0-9]+}}(%esp)
260 ; X86-NEXT: fildll {{[0-9]+}}(%esp)
261 ; X86-NEXT: fstps {{[0-9]+}}(%esp)
262 ; X86-NEXT: movl $32768, %eax # imm = 0x8000
263 ; X86-NEXT: andl {{[0-9]+}}(%esp), %eax
264 ; X86-NEXT: # kill: def $ax killed $ax killed $eax
265 ; X86-NEXT: xorl %edx, %edx
266 ; X86-NEXT: movl %ebp, %esp
267 ; X86-NEXT: popl %ebp
270 ; X64-LABEL: uitofp_signbit_only_fail_bad_width2:
272 ; X64-NEXT: movl %edi, %eax
273 ; X64-NEXT: cvtsi2ss %rax, %xmm0
274 ; X64-NEXT: andps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
276 %f = uitofp i32 %i_in to float
277 %i2xi16 = bitcast float %f to <2 x i16>
278 %r = and <2 x i16> %i2xi16, <i16 32768, i16 32768>
282 define i32 @uitofp_many_bits_fail(i32 %i_in) nounwind {
283 ; X86-LABEL: uitofp_many_bits_fail:
285 ; X86-NEXT: pushl %ebp
286 ; X86-NEXT: movl %esp, %ebp
287 ; X86-NEXT: andl $-8, %esp
288 ; X86-NEXT: subl $16, %esp
289 ; X86-NEXT: movl 8(%ebp), %eax
290 ; X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
291 ; X86-NEXT: movl $0, {{[0-9]+}}(%esp)
292 ; X86-NEXT: fildll {{[0-9]+}}(%esp)
293 ; X86-NEXT: fstps {{[0-9]+}}(%esp)
294 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
295 ; X86-NEXT: andl $1, %eax
296 ; X86-NEXT: movl %ebp, %esp
297 ; X86-NEXT: popl %ebp
300 ; X64-LABEL: uitofp_many_bits_fail:
302 ; X64-NEXT: movl %edi, %eax
303 ; X64-NEXT: cvtsi2ss %rax, %xmm0
304 ; X64-NEXT: movd %xmm0, %eax
305 ; X64-NEXT: andl $1, %eax
307 %f = uitofp i32 %i_in to float
308 %i = bitcast float %f to i32
309 %r = and i32 %i, 2147483649
313 define i32 @uitofp_multiuse_fail(i32 %i_in) nounwind {
314 ; X86-LABEL: uitofp_multiuse_fail:
316 ; X86-NEXT: pushl %ebp
317 ; X86-NEXT: movl %esp, %ebp
318 ; X86-NEXT: andl $-8, %esp
319 ; X86-NEXT: subl $16, %esp
320 ; X86-NEXT: movl 8(%ebp), %eax
321 ; X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
322 ; X86-NEXT: movl $0, {{[0-9]+}}(%esp)
323 ; X86-NEXT: fildll {{[0-9]+}}(%esp)
324 ; X86-NEXT: fstps (%esp)
325 ; X86-NEXT: calll use.i32@PLT
326 ; X86-NEXT: xorl %eax, %eax
327 ; X86-NEXT: movl %ebp, %esp
328 ; X86-NEXT: popl %ebp
331 ; X64-LABEL: uitofp_multiuse_fail:
333 ; X64-NEXT: pushq %rax
334 ; X64-NEXT: movl %edi, %eax
335 ; X64-NEXT: cvtsi2ss %rax, %xmm0
336 ; X64-NEXT: movd %xmm0, %edi
337 ; X64-NEXT: callq use.i32@PLT
338 ; X64-NEXT: xorl %eax, %eax
339 ; X64-NEXT: popq %rcx
341 %f = uitofp i32 %i_in to float
342 %i = bitcast float %f to i32
343 call void @use.i32(i32 %i)
344 %r = and i32 %i, 2147483648
348 define i32 @uitofp_multiuse_okay(i32 %i_in) nounwind {
349 ; X86-LABEL: uitofp_multiuse_okay:
351 ; X86-NEXT: pushl %ebp
352 ; X86-NEXT: movl %esp, %ebp
353 ; X86-NEXT: andl $-8, %esp
354 ; X86-NEXT: subl $16, %esp
355 ; X86-NEXT: movl 8(%ebp), %eax
356 ; X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
357 ; X86-NEXT: movl $0, {{[0-9]+}}(%esp)
358 ; X86-NEXT: fildll {{[0-9]+}}(%esp)
359 ; X86-NEXT: fstps (%esp)
360 ; X86-NEXT: calll use.i1@PLT
361 ; X86-NEXT: xorl %eax, %eax
362 ; X86-NEXT: movl %ebp, %esp
363 ; X86-NEXT: popl %ebp
366 ; X64-LABEL: uitofp_multiuse_okay:
368 ; X64-NEXT: pushq %rax
369 ; X64-NEXT: movl %edi, %eax
370 ; X64-NEXT: cvtsi2ss %rax, %xmm0
371 ; X64-NEXT: movd %xmm0, %edi
372 ; X64-NEXT: callq use.i1@PLT
373 ; X64-NEXT: xorl %eax, %eax
374 ; X64-NEXT: popq %rcx
376 %f = uitofp i32 %i_in to float
377 %i = bitcast float %f to i32
378 %cmp = icmp slt i32 %i, 0
379 call void @use.i1(i32 %i)
380 %r = and i32 %i, 2147483648