Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / lib / builtins / i386 / floatdidf.S
blobd588e770364e5f362f634b34e287c42791805555
1 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
2 // See https://llvm.org/LICENSE.txt for license information.
3 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5 #include "../assembly.h"
7 // double __floatdidf(du_int a);
9 #ifdef __i386__
11 CONST_SECTION
13         .balign 16
14 twop52:
15         .quad 0x4330000000000000
17         .balign 16
18 twop32:
19         .quad 0x41f0000000000000
21 #define REL_ADDR(_a)    (_a)-0b(%eax)
23 .text
24 .balign 4
25 DEFINE_COMPILERRT_FUNCTION(__floatdidf)
26         cvtsi2sd        8(%esp),                        %xmm1
27         movss           4(%esp),                        %xmm0 // low 32 bits of a
28         calll           0f
29 0:      popl            %eax
30         mulsd           REL_ADDR(twop32),       %xmm1 // a_hi as a double (without rounding)
31         movsd           REL_ADDR(twop52),       %xmm2 // 0x1.0p52
32         subsd           %xmm2,                          %xmm1 // a_hi - 0x1p52 (no rounding occurs)
33         orpd            %xmm2,                          %xmm0 // 0x1p52 + a_lo (no rounding occurs)
34         addsd           %xmm1,                          %xmm0 // a_hi + a_lo   (round happens here)
35         movsd           %xmm0,                     4(%esp)
36         fldl       4(%esp)
37         ret
38 END_COMPILERRT_FUNCTION(__floatdidf)
40 #endif // __i386__
42 NO_EXEC_STACK_DIRECTIVE