summaryrefslogtreecommitdiffstats
path: root/contrib/libs/cxxsupp/builtins/floatdidf.c
diff options
context:
space:
mode:
authormikhnenko <[email protected]>2024-11-24 13:46:42 +0300
committermikhnenko <[email protected]>2024-11-24 13:58:43 +0300
commita6b36208ec0041d4370c4cc65716b8e736932115 (patch)
treeb81175804baec4b39ce86a0ebacc90599c135222 /contrib/libs/cxxsupp/builtins/floatdidf.c
parent8b9f13e29dea8f76f11579aae5344ac571d5e604 (diff)
Update compiler_rt to 18.1.8
commit_hash:047370d533b6571fd08cc42584b9f72ca1f8d98d
Diffstat (limited to 'contrib/libs/cxxsupp/builtins/floatdidf.c')
-rw-r--r--contrib/libs/cxxsupp/builtins/floatdidf.c52
1 files changed, 5 insertions, 47 deletions
diff --git a/contrib/libs/cxxsupp/builtins/floatdidf.c b/contrib/libs/cxxsupp/builtins/floatdidf.c
index d37c43b1f2f..6da81f7a05b 100644
--- a/contrib/libs/cxxsupp/builtins/floatdidf.c
+++ b/contrib/libs/cxxsupp/builtins/floatdidf.c
@@ -45,53 +45,11 @@ COMPILER_RT_ABI double __floatdidf(di_int a) {
// flags to set, and we don't want to code-gen to an unknown soft-float
// implementation.
-COMPILER_RT_ABI double __floatdidf(di_int a) {
- if (a == 0)
- return 0.0;
- const unsigned N = sizeof(di_int) * CHAR_BIT;
- const di_int s = a >> (N - 1);
- a = (a ^ s) - s;
- int sd = N - __builtin_clzll(a); // number of significant digits
- int e = sd - 1; // exponent
- if (sd > DBL_MANT_DIG) {
- // start: 0000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQxxxxxxxxxxxxxxxxxx
- // finish: 000000000000000000000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQR
- // 12345678901234567890123456
- // 1 = msb 1 bit
- // P = bit DBL_MANT_DIG-1 bits to the right of 1
- // Q = bit DBL_MANT_DIG bits to the right of 1
- // R = "or" of all bits to the right of Q
- switch (sd) {
- case DBL_MANT_DIG + 1:
- a <<= 1;
- break;
- case DBL_MANT_DIG + 2:
- break;
- default:
- a = ((du_int)a >> (sd - (DBL_MANT_DIG + 2))) |
- ((a & ((du_int)(-1) >> ((N + DBL_MANT_DIG + 2) - sd))) != 0);
- };
- // finish:
- a |= (a & 4) != 0; // Or P into R
- ++a; // round - this step may add a significant bit
- a >>= 2; // dump Q and R
- // a is now rounded to DBL_MANT_DIG or DBL_MANT_DIG+1 bits
- if (a & ((du_int)1 << DBL_MANT_DIG)) {
- a >>= 1;
- ++e;
- }
- // a is now rounded to DBL_MANT_DIG bits
- } else {
- a <<= (DBL_MANT_DIG - sd);
- // a is now rounded to DBL_MANT_DIG bits
- }
- double_bits fb;
- fb.u.s.high = ((su_int)s & 0x80000000) | // sign
- ((su_int)(e + 1023) << 20) | // exponent
- ((su_int)(a >> 32) & 0x000FFFFF); // mantissa-high
- fb.u.s.low = (su_int)a; // mantissa-low
- return fb.f;
-}
+#define SRC_I64
+#define DST_DOUBLE
+#include "int_to_fp_impl.inc"
+
+COMPILER_RT_ABI double __floatdidf(di_int a) { return __floatXiYf__(a); }
#endif
#if defined(__ARM_EABI__)