https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128006
--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Richard Biener <[email protected]>: https://gcc.gnu.org/g:34e1afc66c3239bf5d5dbe8005f8930d84fa20bf commit r17-5395-g34e1afc66c3239bf5d5dbe8005f8930d84fa20bf Author: Richard Biener <[email protected]> Date: Tue Oct 20 09:48:15 2026 +0200 tree-optimization/128006 - only decrement constant integer pow exponents When undistributing a factor X out of a multiplication chain, zero_one_operation uses stmt_is_power_of_op to find a pow/powi call with base X and then removes one factor of X via decrement_power. stmt_is_power_of_op only checked the base, but decrement_power assumes a constant integer exponent. For (x * y) * __builtin_pow (x, 2.5) + z * x with -ffast-math the exponent 2.5 was truncated to 2 and decremented to 1, replacing pow (x, 2.5) with x and miscompiling the expression to x * (x * x * y + z). A non-constant exponent ICEd in decrement_power. Make stmt_is_power_of_op require a constant integer exponent so that the factor is removed from elsewhere in the chain instead. PR tree-optimization/128006 * tree-ssa-reassoc.cc (stmt_is_power_of_op): Require a constant integer exponent. * gcc.dg/tree-ssa/reassoc-52.c: New test. * gcc.dg/tree-ssa/reassoc-53.c: New test.
