]> git.feebdaed.xyz Git - 0xmirror/glibc.git/commitdiff
math: Use math_opt_barrier on ldbl-128 powl underflow/overflow handling
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Fri, 19 Dec 2025 18:52:23 +0000 (15:52 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Mon, 22 Dec 2025 18:55:26 +0000 (15:55 -0300)
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

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
sysdeps/ieee754/ldbl-128/e_powl.c

index 4e20616705633885c661f4bda3175aac7adc0375..9ff5a435739a0617749918f70d2f5f6488f3ee95 100644 (file)
@@ -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)