https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117965
--- Comment #16 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Richard Biener <rgue...@gcc.gnu.org>: https://gcc.gnu.org/g:8da568c885dc90ac5c7d9aee34ae78d5cfb8918c commit r16-906-g8da568c885dc90ac5c7d9aee34ae78d5cfb8918c Author: Richard Biener <rguent...@suse.de> Date: Tue Dec 10 09:55:37 2024 +0100 tree-optimization/117965 - phiprop validity checking is too strict The PR shows that when using std::clamp from the C++ standard library and there is surrounding code using exceptions then phiprop can fail to simplify the code so phiopt can turn the clamping into efficient min/max operations. The validation code is needlessly complicated, steming from the time we had memory-SSA with multiple virtual operands. The following simplifies this, thereby fixing this issue. PR tree-optimization/117965 * tree-ssa-phiprop.cc (phivn_valid_p): Remove. (propagate_with_phi): Pass in virtual PHI node from BB, rewrite load motion validity check to require the same virtual use along all paths. * g++.dg/tree-ssa/pr117965-1.C: New testcase. * g++.dg/tree-ssa/pr117965-2.C: Likewise.