https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127544
--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Roger Sayle <[email protected]>: https://gcc.gnu.org/g:152e49bf66b737d296bf66ac4c1d353d395e6e3b commit r17-4951-g152e49bf66b737d296bf66ac4c1d353d395e6e3b Author: Roger Sayle <[email protected]> Date: Wed Oct 7 09:39:23 2026 +0100 PR tree-optimization/127544: Don't fold pow(-Inf,0.5) to sqrt. This patch fixes PR tree-optimization/127544 by tightening the conditions under which gimple_expand_builtin_pow is allowed to convert pow(x,0.5) into sqrt(x). Specifically, pow(-Inf,0.5) should return +Inf (by POSIX) but sqrt(-Inf) returns NaN, so this transformation is (also) unsafe in the presence of -Inf. The patch also fixes an instance of using REAL_VALUE_ISSIGNALING_NAN when the intended behavior is to check tree_expr_maybe_signaling_nan_p. 2026-10-07 Roger Sayle <[email protected]> gcc/ChangeLog PR tree-optimization/127544 PR tree-optimization/126562 * tree-ssa-math-opts.cc (gimple_expand_builtin_pow): Use tree_expr_maybe_signaling_nan_p insted of REAL_VALUE_ISSIGNALING_NAN to check whether an operand may be a signaling NaN. pow(x,0.5) also can't be transformed to sqrt(x) if x may be -Inf. gcc/testsuite/ChangeLog PR tree-optimization/127544 PR tree-optimization/126562 * gcc.dg/pr127544-1.c: New test case.
