mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-27 14:16:08 +00:00

Fixes https://github.com/llvm/llvm-project/issues/92874 Algorithm: Let `x = (-1)^s * 2^e * (1 + m)`. - Step 1: Range reduction: reduce the exponent with: ``` y = cbrt(x) = (-1)^s * 2^(floor(e/3)) * 2^((e % 3)/3) * (1 + m)^(1/3) ``` - Step 2: Use the first 4 bit fractional bits of `m` to look up for a degree-7 polynomial approximation to: ``` (1 + m)^(1/3) ~ 1 + m * P(m). ``` - Step 3: Perform the multiplication: ``` 2^((e % 3)/3) * (1 + m)^(1/3). ``` - Step 4: Check for exact cases to prevent rounding and clear `FE_INEXACT` floating point exception. - Step 5: Combine with the exponent and sign before converting down to `float` and return.