> Am 06.02.2026 um 21:50 schrieb Roger Sayle <[email protected]>:
>
>
> 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).
>
>
> This patch has been tested on x86_64-pc-linux-gnu with make bootstrap
> and make -k check, both with and without --target_board=unix{-m32},
> with no new failures. Ok for mainline?
Ok
Richard
>
> 2026-02-06 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.
>
>
> Roger
> --
>
> <patchpw5.txt>