diff options
| author | Roger Sayle <roger@nextmovesoftware.com> | 2026-02-03 17:06:25 +0000 |
|---|---|---|
| committer | Roger Sayle <roger@nextmovesoftware.com> | 2026-02-03 17:06:25 +0000 |
| commit | a70bdd86984c0b6cd8520e30ec713e3101c5d45f (patch) | |
| tree | 7167372a04ff9d4d12ebc2a4d86953358287bbf7 /libjava/classpath/lib/java/util | |
| parent | 0fc8da731c7ea37b34614b6eda4c4c38e6f8ba2b (diff) | |
| download | gcc-a70bdd86984c0b6cd8520e30ec713e3101c5d45f.zip gcc-a70bdd86984c0b6cd8520e30ec713e3101c5d45f.tar.gz gcc-a70bdd86984c0b6cd8520e30ec713e3101c5d45f.tar.bz2 | |
PR middle-end/123826: __builtin_pow vs. errno.
This is my proposed solution to PR middle-end/123826. Initially
I thought this would be a "one line change", adding a test for
flag_errno_math to gimple_expand_builtin_pow. Unfortunately
this revealed a second later problem, where pow (with constant
arguments) was still getting evaluated at compile-time, even when
the result is known to overflow.
It's ancient history, but shortly after I added support for pow
as a builtin, I contributed code to evaluate it at compile-time
when the exponent is an integer constant. Since then we now use
MPFR to evaluate libm math functions at compile-time. However
the vestigial call to evaluate pow via real_powi still exists,
and gets invoked after do_mpfr_arg2/mpfr_pow correctly determines
that we shouldn't evaluate pow at compile-time. This patch reorganizes
fold_const_pow paying attention to signaling NaNs (PR 61441)
and flag_errno_math. Most importantly normal cases like pow(2.0,3.0)
and pow(3.0,0.5) still get evaluated at compile-time.
2026-02-03 Roger Sayle <roger@nextmovesoftware.com>
gcc/ChangeLog
PR middle-end/123826
* tree-ssa-math-opts.cc (gimple_expand_builtin_pow): Add test
for flag_errno_math.
* fold-const-call.cc (fold_const_pow): Reorganize, eliminating
call to real_powi, and letting do_mpfr_arg2 do all the heavy
lifting.
gcc/testsuite/ChangeLog
PR middle-end/123826
* gcc.dg/errno-2.c: New test case.
* gcc.dg/errno-3.c: Likewise.
Diffstat (limited to 'libjava/classpath/lib/java/util')
0 files changed, 0 insertions, 0 deletions
