mirror of
https://sourceware.org/git/glibc.git
synced 2025-12-20 01:12:17 +08:00
math: Fix potential underflow on ldbl-128 erfl
The multiplication operation is required only if the branch is taken, and the compiler might not optimize it away. It fixes the following issues when the testcase is built with clang: FAIL: math/test-ldouble-erf Failure: erf (-0x4p-16384): Exception "Underflow" set Failure: erf (0x1p-10000): Exception "Underflow" set Failure: erf (0x3.8b7f12369ded54f38760a41abb84p-16384): Exception "Underflow" set Failure: erf (0x3.8b7f12369ded54f38760a41abb88p-16384): Exception "Underflow" set Failure: erf (0x3.8b7f12369ded54f4p-16384): Exception "Underflow" set Failure: erf (0x3.8b7f12369ded54f8p-16384): Exception "Underflow" set Failure: erf (0x3.8b7f12369ded5518p-16384): Exception "Underflow" set Failure: erf (0x3.8b7f12369ded551cp-16384): Exception "Underflow" set Failure: erf (0x3.8b7f12369ded552p-16384): Exception "Underflow" set Failure: erf (0x4p-16384): Exception "Underflow" set Failure: erf_downward (-0x4p-16384): Exception "Underflow" set Failure: erf_downward (0x1p-10000): Exception "Underflow" set Failure: erf_downward (0x3.8b7f12369ded54f38760a41abb84p-16384): Exception "Underflow" set Failure: erf_downward (0x3.8b7f12369ded54f38760a41abb88p-16384): Exception "Underflow" set Failure: erf_downward (0x3.8b7f12369ded54f4p-16384): Exception "Underflow" set Failure: erf_downward (0x3.8b7f12369ded54f8p-16384): Exception "Underflow" set Failure: erf_downward (0x3.8b7f12369ded5518p-16384): Exception "Underflow" set Failure: erf_downward (0x3.8b7f12369ded551cp-16384): Exception "Underflow" set Failure: erf_downward (0x3.8b7f12369ded552p-16384): Exception "Underflow" set Failure: erf_downward (0x4p-16384): Exception "Underflow" set Failure: erf_towardzero (-0x4p-16384): Exception "Underflow" set Failure: erf_towardzero (0x1p-10000): Exception "Underflow" set Failure: erf_towardzero (0x3.8b7f12369ded54f38760a41abb84p-16384): Exception "Underflow" set Failure: erf_towardzero (0x3.8b7f12369ded54f38760a41abb88p-16384): Exception "Underflow" set Failure: erf_towardzero (0x3.8b7f12369ded54f4p-16384): Exception "Underflow" set Failure: erf_towardzero (0x3.8b7f12369ded54f8p-16384): Exception "Underflow" set Failure: erf_towardzero (0x3.8b7f12369ded5518p-16384): Exception "Underflow" set Failure: erf_towardzero (0x3.8b7f12369ded551cp-16384): Exception "Underflow" set Failure: erf_towardzero (0x3.8b7f12369ded552p-16384): Exception "Underflow" set Failure: erf_towardzero (0x4p-16384): Exception "Underflow" set Failure: erf_upward (-0x4p-16384): Exception "Underflow" set Failure: erf_upward (0x1p-10000): Exception "Underflow" set Failure: erf_upward (0x3.8b7f12369ded54f38760a41abb84p-16384): Exception "Underflow" set Failure: erf_upward (0x3.8b7f12369ded54f38760a41abb88p-16384): Exception "Underflow" set Failure: erf_upward (0x3.8b7f12369ded54f4p-16384): Exception "Underflow" set Failure: erf_upward (0x3.8b7f12369ded54f8p-16384): Exception "Underflow" set Failure: erf_upward (0x3.8b7f12369ded5518p-16384): Exception "Underflow" set Failure: erf_upward (0x3.8b7f12369ded551cp-16384): Exception "Underflow" set Failure: erf_upward (0x3.8b7f12369ded552p-16384): Exception "Underflow" set Failure: erf_upward (0x4p-16384): Exception "Underflow" set Checked on x86_64-linux-gnu and aarch64-linux-gnu with gcc-15 and clang-18. Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
This commit is contained in:
@@ -778,7 +778,6 @@ __erfl (_Float128 x)
|
||||
}
|
||||
u.parts32.w0 = ix;
|
||||
a = u.value;
|
||||
z = x * x;
|
||||
if (ix < 0x3ffec000) /* a < 0.875 */
|
||||
{
|
||||
if (ix < 0x3fc60000) /* |x|<2**-57 */
|
||||
@@ -792,6 +791,7 @@ __erfl (_Float128 x)
|
||||
}
|
||||
return x + efx * x;
|
||||
}
|
||||
z = x * x;
|
||||
y = a + a * neval (z, TN1, NTN1) / deval (z, TD1, NTD1);
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user