https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111860
--- Comment #6 from Tamar Christina <tnfchris at gcc dot gnu.org> --- Ok, so the problem is that the loop never creates memory references, and so after redirecting the edges when we update the new references we do so by trying to update the PHI nodes. But since the loop has no MEM phi node there's nothing to update but we created a new artificial node during redirect. Because there's no PHI node that means that adjust_phi_and_debug_stmts isn't strong enough here. So I can either remove phi nodes whom's SSA vars haven't been defined inside the loop have not been defined in the body, or I'll need to replace adjust_phi_and_debug_stmts with something that goes through all uses inside the new loop and exit. Which do you prefer richi? It seems like removing the PHI node after redirect is the simplest one and one less thing to keep updated.