8 static inline uint32_t mul32(uint32_t a, uint32_t b)
10 return (uint64_t)a*b >> 32;
13 /* see sqrt.c for more detailed comments. */
17 uint32_t ix, m, m1, m0, even, ey;
20 if (predict_false(ix - 0x00800000 >= 0x7f800000 - 0x00800000)) {
21 /* x < 0x1p-126 or inf or nan. */
27 return __math_invalidf(x);
28 /* x is subnormal, normalize it. */
29 ix = asuint(x * 0x1p23f);
33 /* x = 4^e m; with int e and m in [1, 4). */
34 even = ix & 0x00800000;
35 m1 = (ix << 8) | 0x80000000;
36 m0 = (ix << 7) & 0x7fffffff;
39 /* 2^e is the exponent part of the return value. */
41 ey += 0x3f800000 >> 1;
44 /* compute r ~ 1/sqrt(m), s ~ sqrt(m) with 2 goldschmidt iterations. */
45 static const uint32_t three = 0xc0000000;
46 uint32_t r, s, d, u, i;
48 r = (uint32_t)__rsqrt_tab[i] << 16;
49 /* |r*sqrt(m) - 1| < 0x1p-8 */
51 /* |s/sqrt(m) - 1| < 0x1p-8 */
55 /* |r*sqrt(m) - 1| < 0x1.7bp-16 */
57 /* |s/sqrt(m) - 1| < 0x1.7bp-16 */
61 /* -0x1.03p-28 < s/sqrt(m) - 1 < 0x1.fp-31 */
63 /* s < sqrt(m) < s + 0x1.08p-23 */
65 /* compute nearest rounded result. */
76 /* handle rounding and inexact exception. */
77 uint32_t tiny = predict_false(d2==0) ? 0 : 0x01000000;
78 tiny |= (d1^d2) & 0x80000000;
80 y = eval_as_float(y + t);