mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-25 16:55:11 +01:00
Add medium-precision-binary floating point impl
name old time/op new time/op delta strconv_parse_number_f64_1_lsh53_add0/clang5 218ns ± 1% 100ns ± 0% -54.13% (p=0.016 n=5+4) strconv_parse_number_f64_1_lsh53_add1/clang5 716ns ± 2% 741ns ± 1% +3.46% (p=0.008 n=5+5) strconv_parse_number_f64_pi_long/clang5 438ns ± 2% 153ns ± 1% -65.19% (p=0.008 n=5+5) strconv_parse_number_f64_pi_short/clang5 174ns ± 2% 62ns ± 2% -64.37% (p=0.008 n=5+5) strconv_parse_number_f64_1_lsh53_add0/gcc7 221ns ± 1% 97ns ± 4% -56.25% (p=0.008 n=5+5) strconv_parse_number_f64_1_lsh53_add1/gcc7 742ns ± 1% 757ns ± 0% +2.02% (p=0.008 n=5+5) strconv_parse_number_f64_pi_long/gcc7 477ns ± 1% 151ns ± 3% -68.40% (p=0.008 n=5+5) strconv_parse_number_f64_pi_short/gcc7 191ns ± 1% 55ns ± 0% -71.14% (p=0.000 n=5+4)
This commit is contained in:
1 parent
3f0d66285f
commit
d587c9e4fa
8 files changed
+1300
-42
No files matched your search
@@ -383,6 +383,80 @@ wuffs_base__u64__sat_sub(uint64_t x, uint64_t y) {
|
||||
return res;
|
||||
}
|
||||
|
||||
// --------
|
||||
|
||||
typedef struct {
|
||||
uint64_t hi;
|
||||
uint64_t lo;
|
||||
} wuffs_base__multiply_u64__output;
|
||||
|
||||
// wuffs_base__multiply_u64 returns x*y as a 128-bit value.
|
||||
//
|
||||
// The maximum inclusive output hi_lo is 0xFFFFFFFFFFFFFFFE_0000000000000001.
|
||||
static inline wuffs_base__multiply_u64__output //
|
||||
wuffs_base__multiply_u64(uint64_t x, uint64_t y) {
|
||||
uint64_t x0 = x & 0xFFFFFFFF;
|
||||
uint64_t x1 = x >> 32;
|
||||
uint64_t y0 = y & 0xFFFFFFFF;
|
||||
uint64_t y1 = y >> 32;
|
||||
uint64_t w0 = x0 * y0;
|
||||
uint64_t t = (x1 * y0) + (w0 >> 32);
|
||||
uint64_t w1 = t & 0xFFFFFFFF;
|
||||
uint64_t w2 = t >> 32;
|
||||
w1 += x0 * y1;
|
||||
wuffs_base__multiply_u64__output o;
|
||||
o.hi = (x1 * y1) + w2 + (w1 >> 32);
|
||||
o.lo = x * y;
|
||||
return o;
|
||||
}
|
||||
|
||||
// --------
|
||||
|
||||
#if defined(__GNUC__) && (__SIZEOF_LONG__ == 8)
|
||||
|
||||
static inline uint32_t //
|
||||
wuffs_base__count_leading_zeroes_u64(uint64_t u) {
|
||||
return u ? ((uint32_t)(__builtin_clzl(u))) : 64u;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static inline uint32_t //
|
||||
wuffs_base__count_leading_zeroes_u64(uint64_t u) {
|
||||
if (u == 0) {
|
||||
return 64;
|
||||
}
|
||||
|
||||
uint32_t n = 0;
|
||||
if ((u >> 32) == 0) {
|
||||
n |= 32;
|
||||
u <<= 32;
|
||||
}
|
||||
if ((u >> 48) == 0) {
|
||||
n |= 16;
|
||||
u <<= 16;
|
||||
}
|
||||
if ((u >> 56) == 0) {
|
||||
n |= 8;
|
||||
u <<= 8;
|
||||
}
|
||||
if ((u >> 60) == 0) {
|
||||
n |= 4;
|
||||
u <<= 4;
|
||||
}
|
||||
if ((u >> 62) == 0) {
|
||||
n |= 2;
|
||||
u <<= 2;
|
||||
}
|
||||
if ((u >> 63) == 0) {
|
||||
n |= 1;
|
||||
u <<= 1;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
#endif // defined(__GNUC__) && (__SIZEOF_LONG__ == 8)
|
||||
|
||||
// --------
|
||||
|
||||
#define wuffs_base__load_u8be__no_bounds_check \
|
||||
|
||||
Reference in new issue
Block a user