https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116747
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|15.0 |12.5 --- Comment #13 from Andrew Pinski <pinskia at gcc dot gnu.org> --- This fixes the ICE but I am not 100% sure if this is the right approach or should we change how write after write checks are done. diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc index d43832b390b..6da60771702 100644 --- a/gcc/tree-ssa-phiopt.cc +++ b/gcc/tree-ssa-phiopt.cc @@ -3451,7 +3451,10 @@ cond_if_else_store_replacement_1 (basic_block then_bb, basic_block else_bb, || else_assign == NULL || !gimple_assign_single_p (else_assign) || gimple_clobber_p (else_assign) - || gimple_has_volatile_ops (else_assign)) + || gimple_has_volatile_ops (else_assign) + /* If there was undefined behavior, else_assign might + have been removed already. */ + || !gimple_bb (else_assign)) return false; lhs = gimple_assign_lhs (then_assign);