* @brief Compute an approximate log2(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 */
| 414 | * https://jrfonseca.blogspot.com/2008/09/fast-sse2-pow-tables-or-polynomials.html |
| 415 | */ |
| 416 | static ASTCENC_SIMD_INLINE vfloat4 log2(vfloat4 x) |
| 417 | { |
| 418 | vint4 exp(0x7F800000); |
| 419 | vint4 mant(0x007FFFFF); |
| 420 | vint4 one(0x3F800000); |
| 421 | |
| 422 | vint4 i = float_as_int(x); |
| 423 | |
| 424 | vfloat4 e = int_to_float(lsr<23>(i & exp) - 127); |
| 425 | |
| 426 | vfloat4 m = int_as_float((i & mant) | one); |
| 427 | |
| 428 | // Polynomial fit of log2(x)/(x - 1), for x in range [1, 2) |
| 429 | vfloat4 p = POLY4(m, |
| 430 | 2.8882704548164776201f, |
| 431 | -2.52074962577807006663f, |
| 432 | 1.48116647521213171641f, |
| 433 | -0.465725644288844778798f, |
| 434 | 0.0596515482674574969533f); |
| 435 | |
| 436 | // Increases the polynomial degree, but ensures that log2(1) == 0 |
| 437 | p = p * (m - 1.0f); |
| 438 | |
| 439 | return p + e; |
| 440 | } |
| 441 | |
| 442 | /** |
| 443 | * @brief Compute an approximate pow(x, y) for each lane in the vector. |
no test coverage detected