* @brief Compute an approximate exp2(x) for each lane in the vector. * * Based on 5th degree minimax polynomials, ported from this blog * https://jrfonseca.blogspot.com/2008/09/fast-sse2-pow-tables-or-polynomials.html */
| 386 | * https://jrfonseca.blogspot.com/2008/09/fast-sse2-pow-tables-or-polynomials.html |
| 387 | */ |
| 388 | static ASTCENC_SIMD_INLINE vfloat4 exp2(vfloat4 x) |
| 389 | { |
| 390 | x = clamp(-126.99999f, 129.0f, x); |
| 391 | |
| 392 | vint4 ipart = float_to_int(x - 0.5f); |
| 393 | vfloat4 fpart = x - int_to_float(ipart); |
| 394 | |
| 395 | // Integer contrib, using 1 << ipart |
| 396 | vfloat4 iexp = int_as_float(lsl<23>(ipart + 127)); |
| 397 | |
| 398 | // Fractional contrib, using polynomial fit of 2^x in range [-0.5, 0.5) |
| 399 | vfloat4 fexp = POLY5(fpart, |
| 400 | 9.9999994e-1f, |
| 401 | 6.9315308e-1f, |
| 402 | 2.4015361e-1f, |
| 403 | 5.5826318e-2f, |
| 404 | 8.9893397e-3f, |
| 405 | 1.8775767e-3f); |
| 406 | |
| 407 | return iexp * fexp; |
| 408 | } |
| 409 | |
| 410 | /** |
| 411 | * @brief Compute an approximate log2(x) for each lane in the vector. |
no test coverage detected