[PATCH] D126386: [ModuloSchedule] Fix terminator update when peeling.
Hendrik Greving via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 25 11:43:16 PDT 2022
hgreving updated this revision to Diff 432062.
hgreving added a comment.
Updates patch. Let's do it straight forward and support cases where no branch is needed to the fallthrough.
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.432062.patch
Type: text/x-patch
Size: 1418 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220525/cd39cc32/attachment.bin>
More information about the llvm-commits
mailing list