summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/ModuloSchedule.cpp
diff options
context:
space:
mode:
authorMitch Phillips <mitchphillips@outlook.com>2019-09-20 20:25:16 +0000
committerMitch Phillips <mitchphillips@outlook.com>2019-09-20 20:25:16 +0000
commit72a3d8597da5cb50f3a21ba8a2f822117459af34 (patch)
treedf3e193898f34c22018d097e4b0f733bc7714a9d /llvm/lib/CodeGen/ModuloSchedule.cpp
parentce7cfbccc63ba318bed00aef65dab49adc6f43c8 (diff)
downloadbcm5719-llvm-72a3d8597da5cb50f3a21ba8a2f822117459af34.tar.gz
bcm5719-llvm-72a3d8597da5cb50f3a21ba8a2f822117459af34.zip
Revert "[MachinePipeliner] Improve the TargetInstrInfo API analyzeLoop/reduceLoopCount"
This commit broke the ASan buildbot. See comments in rL372376 for more information. This reverts commit 15e27b0b6d9d51362fad85dbe95ac5b3fadf0a06. llvm-svn: 372425
Diffstat (limited to 'llvm/lib/CodeGen/ModuloSchedule.cpp')
-rw-r--r--llvm/lib/CodeGen/ModuloSchedule.cpp40
1 files changed, 23 insertions, 17 deletions
diff --git a/llvm/lib/CodeGen/ModuloSchedule.cpp b/llvm/lib/CodeGen/ModuloSchedule.cpp
index aa5e86e97d1..8bea4037f54 100644
--- a/llvm/lib/CodeGen/ModuloSchedule.cpp
+++ b/llvm/lib/CodeGen/ModuloSchedule.cpp
@@ -105,9 +105,6 @@ void ModuloScheduleExpander::expand() {
}
void ModuloScheduleExpander::generatePipelinedLoop() {
- LoopInfo = TII->analyzeLoopForPipelining(BB);
- assert(LoopInfo && "Must be able to analyze loop!");
-
// Create a new basic block for the kernel and add it to the CFG.
MachineBasicBlock *KernelBB = MF.CreateMachineBasicBlock(BB->getBasicBlock());
@@ -850,6 +847,10 @@ void ModuloScheduleExpander::addBranches(MachineBasicBlock &PreheaderBB,
MBBVectorTy &EpilogBBs,
ValueMapTy *VRMap) {
assert(PrologBBs.size() == EpilogBBs.size() && "Prolog/Epilog mismatch");
+ MachineInstr *IndVar;
+ MachineInstr *Cmp;
+ if (TII->analyzeLoop(*Schedule.getLoop(), IndVar, Cmp))
+ llvm_unreachable("Must be able to analyze loop!");
MachineBasicBlock *LastPro = KernelBB;
MachineBasicBlock *LastEpi = KernelBB;
@@ -857,20 +858,32 @@ void ModuloScheduleExpander::addBranches(MachineBasicBlock &PreheaderBB,
// to the first prolog and the last epilog blocks.
SmallVector<MachineInstr *, 4> PrevInsts;
unsigned MaxIter = PrologBBs.size() - 1;
+ unsigned LC = UINT_MAX;
+ unsigned LCMin = UINT_MAX;
for (unsigned i = 0, j = MaxIter; i <= MaxIter; ++i, --j) {
// Add branches to the prolog that go to the corresponding
// epilog, and the fall-thru prolog/kernel block.
MachineBasicBlock *Prolog = PrologBBs[j];
MachineBasicBlock *Epilog = EpilogBBs[i];
-
+ // We've executed one iteration, so decrement the loop count and check for
+ // the loop end.
SmallVector<MachineOperand, 4> Cond;
- Optional<bool> StaticallyGreater =
- LoopInfo->createTripCountGreaterCondition(j + 1, *Prolog, Cond);
+ // Check if the LOOP0 has already been removed. If so, then there is no need
+ // to reduce the trip count.
+ if (LC != 0)
+ LC = TII->reduceLoopCount(*Prolog, PreheaderBB, IndVar, *Cmp, Cond,
+ PrevInsts, j, MaxIter);
+
+ // Record the value of the first trip count, which is used to determine if
+ // branches and blocks can be removed for constant trip counts.
+ if (LCMin == UINT_MAX)
+ LCMin = LC;
+
unsigned numAdded = 0;
- if (!StaticallyGreater.hasValue()) {
+ if (Register::isVirtualRegister(LC)) {
Prolog->addSuccessor(Epilog);
numAdded = TII->insertBranch(*Prolog, Epilog, LastPro, Cond, DebugLoc());
- } else if (*StaticallyGreater == false) {
+ } else if (j >= LCMin) {
Prolog->addSuccessor(Epilog);
Prolog->removeSuccessor(LastPro);
LastEpi->removeSuccessor(Epilog);
@@ -881,12 +894,10 @@ void ModuloScheduleExpander::addBranches(MachineBasicBlock &PreheaderBB,
LastEpi->clear();
LastEpi->eraseFromParent();
}
- if (LastPro == KernelBB) {
- LoopInfo->disposed();
- NewKernel = nullptr;
- }
LastPro->clear();
LastPro->eraseFromParent();
+ if (LastPro == KernelBB)
+ NewKernel = nullptr;
} else {
numAdded = TII->insertBranch(*Prolog, LastPro, nullptr, Cond, DebugLoc());
removePhis(Epilog, Prolog);
@@ -898,11 +909,6 @@ void ModuloScheduleExpander::addBranches(MachineBasicBlock &PreheaderBB,
I != E && numAdded > 0; ++I, --numAdded)
updateInstruction(&*I, false, j, 0, VRMap);
}
-
- if (NewKernel) {
- LoopInfo->setPreheader(PrologBBs[MaxIter]);
- LoopInfo->adjustTripCount(-(MaxIter + 1));
- }
}
/// Return true if we can compute the amount the instruction changes
OpenPOWER on IntegriCloud