[llvm] [LoopDeletion] RAUW single-entry header phis after breakLoopBackedge. (PR #106046)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 26 02:46:10 PDT 2024


================
@@ -759,6 +759,13 @@ void llvm::breakLoopBackedge(Loop *L, DominatorTree &DT, ScalarEvolution &SE,
         DomTreeUpdater DTU(&DT, DomTreeUpdater::UpdateStrategy::Eager);
         Header->removePredecessor(Latch, true);
 
+        for (PHINode &PN : Header->phis()) {
+          assert(PN.getNumIncomingValues() == 1 &&
+                 "header phi has more than one incoming value after removing "
+                 "single latch");
+          PN.replaceAllUsesWith(PN.getIncomingValue(0));
+        }
----------------
nikic wrote:

Shouldn't this also happen in the generic (SplitEdge) case?

https://github.com/llvm/llvm-project/pull/106046


More information about the llvm-commits mailing list