[PATCH v2 4/5] math: Use math_opt_barrier on ldbl-128 powl underflow/overflow handling
Adhemerval Zanella
adhemerval.zanella@linaro.org
Fri Dec 19 18:52:23 GMT 2025
This avoids compiler to move the operation before the 'iy' compare.
It fixes math/test-float128-pow regreesions when building with clang [1]:
Failure: pow (-0x1.000002p+0, 0xf.ffffffffffff8p+1020): Exception "Underflow" set
Failure: pow (-0x1.000002p+0, 0xf.ffffffffffffbffffffffffffcp+1020): Exception "Underflow" set
Failure: pow (-0x1.000002p+0, 0xf.fffffffffffffffffffffffffff8p+16380): Exception "Underflow" set
Failure: pow (-0x1.000002p+0, 0xf.fffffffffffffffp+16380): Exception "Underflow" set
Failure: pow (-0x1.000002p+0, 0xf.fffffp+124): Exception "Underflow" set
Failure: pow (-0x1.00000ep+0, 0xf.ffffffffffff8p+1020): Exception "Underflow" set
Failure: pow (-0x1.00000ep+0, 0xf.ffffffffffffbffffffffffffcp+1020): Exception "Underflow" set
Failure: pow (-0x1.00000ep+0, 0xf.fffffffffffffffffffffffffff8p+16380): Exception "Underflow" set
Failure: pow (-0x1.00000ep+0, 0xf.fffffffffffffffp+16380): Exception "Underflow" set
Failure: pow (-0x2p+0, -0xf.ffffffffffff8p+1020): Exception "Overflow" set
Failure: pow (-0x2p+0, -0xf.ffffffffffffbffffffffffffcp+1020): Exception "Overflow" set
Failure: pow (-0x2p+0, -0xf.fffffffffffffffffffffffffff8p+16380): Exception "Overflow" set
Failure: pow (-0x2p+0, -0xf.fffffffffffffffp+16380): Exception "Overflow" set
Failure: pow (-0x2p+0, -0xf.fffffp+124): Exception "Overflow" set
Failure: pow (-0x2p+0, 0xf.ffffffffffff8p+1020): Exception "Underflow" set
Failure: pow (-0x2p+0, 0xf.ffffffffffffbffffffffffffcp+1020): Exception "Underflow" set
Failure: pow (-0x2p+0, 0xf.fffffffffffffffffffffffffff8p+16380): Exception "Underflow" set
Failure: pow (-0x2p+0, 0xf.fffffffffffffffp+16380): Exception "Underflow" set
Failure: pow (-0x2p+0, 0xf.fffffp+124): Exception "Underflow" set
[...]
Checked on x86_64-linux-gnu and aarch64-linux-gnu with gcc-15 and
clang-18.
[1] https://github.com/llvm/llvm-project/issues/173080
---
sysdeps/ieee754/ldbl-128/e_powl.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/sysdeps/ieee754/ldbl-128/e_powl.c b/sysdeps/ieee754/ldbl-128/e_powl.c
index 4e20616705..9ff5a43573 100644
--- a/sysdeps/ieee754/ldbl-128/e_powl.c
+++ b/sysdeps/ieee754/ldbl-128/e_powl.c
@@ -279,9 +279,11 @@ __ieee754_powl (_Float128 x, _Float128 y)
if (iy > 0x407d654b)
{
if (ix <= 0x3ffeffff)
- return (hy < 0) ? huge * huge : tiny * tiny;
+ return (hy < 0) ? math_opt_barrier (huge * huge)
+ : math_opt_barrier (tiny * tiny);
if (ix >= 0x3fff0000)
- return (hy > 0) ? huge * huge : tiny * tiny;
+ return (hy > 0) ? math_opt_barrier (huge * huge)
+ : math_opt_barrier (tiny * tiny);
}
/* over/underflow if x is not close to one */
if (ix < 0x3ffeffff)
--
2.43.0
More information about the Libc-alpha
mailing list