[libc-commits] [PATCH] D143116: Add scalbn, scalbnf, scalbnl.

Renyi Chen via Phabricator via libc-commits libc-commits at lists.llvm.org
Thu Feb 2 15:34:35 PST 2023


renyichen added a comment.

`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.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D143116/new/

https://reviews.llvm.org/D143116



More information about the libc-commits mailing list