Implement scalbn via fptuil::ldexp for FLT_RADIX==2 case.
"unimplemented" otherwise.
Details
Details
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Comment Actions
scalbn is supposed to compute more efficiently than directly performing x*FLT_RADIX^n as described in C99 Standard (in existing implementations, it doesn't necessary holds).
A rough compare has been performed locally by fixing n and test over the range defined in the existing infra for scalbnf(x, n):
llvmlibc | glibc | directly calc x*exp2f(n) | |
n = 10 denormal range | |||
avg runtime (ns/op) | 13.7849 | 57.5703 | 58.7697 |
n = 10 normal range | |||
avg runtime (ns/op) | 9.71103 | 10.7406 | 13.6085 |
llvmlibc outperforms both glibc and directly calc.
Current optimization mechanisms in fputil::ldexp(): 1. early return if n is outside [-MAX_EXPONENT-MantissaWidth-1, MAX_EXPONENT+MantissaWidth+1]. 2. bit manipulation.
libc/src/__support/FPUtil/ManipulationFunctions.h | ||
---|---|---|
119–122 ↗ | (On Diff #494447) | These are exceptional cases, adding unlikely to these 2 conditions could potentially speed up the main cases. |