https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98455
--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> --- The issue is you are leaving the virtual PHI arguments NULL and thus ssa_redirect_edge runs into if (def == NULL_TREE) continue; but then later flush_pending_stmts expects a 1:1 correspondence of PHI and argument per edge. The fix is to either put in bare gimple_vop (cfun) symbols (you'll rename later anyway) in the PHI argument place or try to make the CFG workers deal with missing arguments. Note missing args are not really valid. After if-to-switch: <bb 5> : # .MEM_2 = PHI <.MEM_3(D)(3), .MEM_2(7), .MEM_3(D)(2), .MEM_2(9), .MEM_2(5), (6)> # uc$1_12 = PHI <2.0e+0(3), uc$1_12(7), 2.0e+0(2), 0.0(9), uc$1_12(5), uc$1_12(6)> <L12>: if (io_6(D) == 0) note the missing MEM argument in the edge from 6 to 5