https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103317
--- Comment #12 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The trunk branch has been updated by Andrew Pinski <pins...@gcc.gnu.org>: https://gcc.gnu.org/g:09d462146b3107c665265b11ad925c61a91c6efb commit r12-5393-g09d462146b3107c665265b11ad925c61a91c6efb Author: Andrew Pinski <apin...@marvell.com> Date: Thu Nov 18 23:38:30 2021 +0000 Fix PR 103317, ICE after PHI-OPT, minmax_replacement producing invalid SSA The problem is r12-5300-gf98f373dd822b35c allows phiopt to recognize more basic blocks but missed one location where the basic block does not need to be empty but still needs to have a single predecessor. This patch fixes that over sight. OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. PR tree-optimization/103317 gcc/ChangeLog: * tree-ssa-phiopt.c (minmax_replacement): For the non empty middle bb case, check to make sure it has a single predecessor. gcc/testsuite/ChangeLog: * gcc.c-torture/compile/pr103317-1.c: New test.