* @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 */
| 362 | * https://jrfonseca.blogspot.com/2008/09/fast-sse2-pow-tables-or-polynomials.html |
| 363 | */ |
| 364 | static ASTCENC_SIMD_INLINE vfloat4 exp2(vfloat4 x) |
| 365 | { |
| 366 | x = clamp(-126.99999f, 129.0f, x); |
| 367 | |
| 368 | vint4 ipart = float_to_int(x - 0.5f); |
| 369 | vfloat4 fpart = x - int_to_float(ipart); |
| 370 | |
| 371 | // Integer contrib, using 1 << ipart |
| 372 | vfloat4 iexp = int_as_float(lsl<23>(ipart + 127)); |
| 373 | |
| 374 | // Fractional contrib, using polynomial fit of 2^x in range [-0.5, 0.5) |
| 375 | vfloat4 fexp = POLY5(fpart, |
| 376 | 9.9999994e-1f, |
| 377 | 6.9315308e-1f, |
| 378 | 2.4015361e-1f, |
| 379 | 5.5826318e-2f, |
| 380 | 8.9893397e-3f, |
| 381 | 1.8775767e-3f); |
| 382 | |
| 383 | return iexp * fexp; |
| 384 | } |
| 385 | |
| 386 | /** |
| 387 | * @brief Compute an approximate log2(x) for each lane in the vector. |
no test coverage detected