Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / lib / builtins / x86_64 / floatundidf.S
blob7f6ef3bbb6bf05405f4f959ab0a874a3e670a8f3
1 //===-- floatundidf.S - Implement __floatundidf for x86_64 ----------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements __floatundidf for the compiler_rt library.
11 //===----------------------------------------------------------------------===//
13 #include "../assembly.h"
15 // double __floatundidf(du_int a);
17 #ifdef __x86_64__
19 CONST_SECTION
21         .balign 16
22 twop52:
23         .quad 0x4330000000000000
25         .balign 16
26 twop84_plus_twop52:
27         .quad 0x4530000000100000
29         .balign 16
30 twop84:
31         .quad 0x4530000000000000
33 #define REL_ADDR(_a)    (_a)(%rip)
35 .text
36 .balign 4
37 DEFINE_COMPILERRT_FUNCTION(__floatundidf)
38         movd    %edi,                                                   %xmm0 // low 32 bits of a
39         shrq    $32,                                                    %rdi  // high 32 bits of a
40         orq             REL_ADDR(twop84),                               %rdi  // 0x1p84 + a_hi (no rounding occurs)
41         orpd    REL_ADDR(twop52),                               %xmm0 // 0x1p52 + a_lo (no rounding occurs)
42         movd    %rdi,                                                   %xmm1
43         subsd   REL_ADDR(twop84_plus_twop52),   %xmm1 // a_hi - 0x1p52 (no rounding occurs)
44         addsd   %xmm1,                                                  %xmm0 // a_hi + a_lo   (round happens here)
45         ret
46 END_COMPILERRT_FUNCTION(__floatundidf)
48 #endif // __x86_64__
50 NO_EXEC_STACK_DIRECTIVE