[PATCH] D126386: [ModuloSchedule] Fix terminator update when peeling.

Hendrik Greving via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 6 12:52:48 PDT 2022


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa43d25734a46: [ModuloSchedule] Fix terminator update when peeling. (authored by hgreving).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126386/new/

https://reviews.llvm.org/D126386

Files:
  llvm/lib/CodeGen/MachineLoopUtils.cpp
  llvm/lib/CodeGen/ModuloSchedule.cpp


Index: llvm/lib/CodeGen/ModuloSchedule.cpp
===================================================================
--- llvm/lib/CodeGen/ModuloSchedule.cpp
+++ llvm/lib/CodeGen/ModuloSchedule.cpp
@@ -1797,10 +1797,10 @@
 
   // Iterate in reverse order over all instructions, remapping as we go.
   for (MachineBasicBlock *B : reverse(Blocks)) {
-    for (auto I = B->getFirstInstrTerminator()->getReverseIterator();
+    for (auto I = B->instr_rbegin();
          I != std::next(B->getFirstNonPHI()->getReverseIterator());) {
-      MachineInstr *MI = &*I++;
-      rewriteUsesOf(MI);
+      MachineBasicBlock::reverse_instr_iterator MI = I++;
+      rewriteUsesOf(&*MI);
     }
   }
   for (auto *MI : IllegalPhisToDelete) {
Index: llvm/lib/CodeGen/MachineLoopUtils.cpp
===================================================================
--- llvm/lib/CodeGen/MachineLoopUtils.cpp
+++ llvm/lib/CodeGen/MachineLoopUtils.cpp
@@ -103,11 +103,10 @@
 
   DebugLoc DL;
   if (Direction == LPD_Front) {
-    Preheader->replaceSuccessor(Loop, NewBB);
+    Preheader->ReplaceUsesOfBlockWith(Loop, NewBB);
     NewBB->addSuccessor(Loop);
     Loop->replacePhiUsesWith(Preheader, NewBB);
-    if (TII->removeBranch(*Preheader) > 0)
-      TII->insertBranch(*Preheader, NewBB, nullptr, {}, DL);
+    Preheader->updateTerminator(Loop);
     TII->removeBranch(*NewBB);
     TII->insertBranch(*NewBB, Loop, nullptr, {}, DL);
   } else {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126386.434569.patch
Type: text/x-patch
Size: 1418 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220606/0ed67ca4/attachment.bin>


More information about the llvm-commits mailing list