https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123826
--- Comment #4 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:30886aeca75076bfd50b0fff8d76942603bee763 commit r16-7377-g30886aeca75076bfd50b0fff8d76942603bee763 Author: Roger Sayle <[email protected]> Date: Sat Feb 7 08:04:40 2026 +0000 PR tree-optimization/123958: FMA vs pow(x,2.0) [vs errno] This is my proposed solution to PR123958 (and PR124002) which is a regression exposed by my recent change to avoid expanding pow(x,2.0) to x*x with -fmath-errno (the default) when we can't guarantee that errno shouldn't be updated. The problem is that the logic to convert pow(x,2.0) was also duplicated (but unused) in tree-ssa-math-opts where it's intended to perform this conversion in order to expose fused-multiply-add instructions when supported by the target. The issue is that this "vestigial" code has bit-rotten over the years, and incorrectly updates vdefs when changing vops, tiggering an ICE. My pragmatic solution to this is to simply delete the problematic code; the decision of whether pow(x,2.0) should be expanded is left to the earlier pow_expand pass (which is what it's designed for), and the later FMA pass can make use of any resulting FP multiplications. Not only does this avoid the PHI related ICE, but also fixes the original PR (on updating errno) on targets with FMA, e.g. aarch64 and recent x86_64 architectures (such as -march=znver3). 2026-02-07 Roger Sayle <[email protected]> gcc/ChangeLog PR middle-end/123826 PR tree-optimization/123958 PR c++/124002 * tree-ssa-math-opts.cc (math_opts_dom_walker::after_dom_children): Delete code that (mis)handled conversion of pow(x,2.0) to x*x. gcc/testsuite/ChangeLog PR middle-end/123826 PR tree-optimization/123958 PR c++/124002 * g++.target/i386/pr124002.C: New test case. * gcc.target/i386/pr123958.c: Likewise. * gcc.dg/errno-4.c: Likewise.
