Unverified Commit bc7a3bd8 authored by lntue's avatar lntue Committed by GitHub
Browse files

[libc][math] Implement powf function correctly rounded to all rounding modes. (#71188)

We compute `pow(x, y)` using the formula
```
  pow(x, y) = x^y = 2^(y * log2(x))
```
We follow similar steps as in `log2f(x)` and `exp2f(x)`, by breaking
down into `hi + mid + lo` parts, in which `hi` parts are computed using
the exponent field directly, `mid` parts will use look-up tables, and
`lo` parts are approximated by polynomials.

We add some speedup for common use-cases:
```
  pow(2, y) = exp2(y)
  pow(10, y) = exp10(y)
  pow(x, 2) = x * x
  pow(x, 1/2) = sqrt(x)
  pow(x, -1/2) = rsqrt(x) - to be added
```
parent 0156b6ed
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -199,6 +199,7 @@ set(TARGET_LIBM_ENTRYPOINTS
    libc.src.math.nextafter
    libc.src.math.nextafterf
    libc.src.math.nextafterl
    libc.src.math.powf
    libc.src.math.remainderf
    libc.src.math.remainder
    libc.src.math.remainderl
+1 −0
Original line number Diff line number Diff line
@@ -316,6 +316,7 @@ set(TARGET_LIBM_ENTRYPOINTS
    libc.src.math.nextafter
    libc.src.math.nextafterf
    libc.src.math.nextafterl
    libc.src.math.powf
    libc.src.math.remainderf
    libc.src.math.remainder
    libc.src.math.remainderl
+1 −0
Original line number Diff line number Diff line
@@ -325,6 +325,7 @@ set(TARGET_LIBM_ENTRYPOINTS
    libc.src.math.nextafter
    libc.src.math.nextafterf
    libc.src.math.nextafterl
    libc.src.math.powf
    libc.src.math.remainderf
    libc.src.math.remainder
    libc.src.math.remainderl
+1 −0
Original line number Diff line number Diff line
@@ -329,6 +329,7 @@ set(TARGET_LIBM_ENTRYPOINTS
    libc.src.math.nextafter
    libc.src.math.nextafterf
    libc.src.math.nextafterl
    libc.src.math.powf
    libc.src.math.remainderf
    libc.src.math.remainder
    libc.src.math.remainderl
+1 −0
Original line number Diff line number Diff line
@@ -198,6 +198,7 @@ set(TARGET_LIBM_ENTRYPOINTS
    libc.src.math.nextafter
    libc.src.math.nextafterf
    libc.src.math.nextafterl
    libc.src.math.powf
    libc.src.math.remainderf
    libc.src.math.remainder
    libc.src.math.remainderl
Loading