forked from OSchip/llvm-project
[LoopInterchange] Add more debug messages to currentLimitations().
Summary: This makes it easier to find out which limitation prevented this pass from doing its work. Reviewers: karthikthecool, mzolotukhin, efriedma, mcrosier Reviewed By: mcrosier Subscribers: mcrosier, llvm-commits Differential Revision: https://reviews.llvm.org/D34940 llvm-svn: 307035
This commit is contained in:
parent
29e0a99297
commit
4eeff394d3
|
@ -757,8 +757,11 @@ bool LoopInterchangeLegality::currentLimitations() {
|
|||
PHINode *InnerInductionVar;
|
||||
SmallVector<PHINode *, 8> Inductions;
|
||||
SmallVector<PHINode *, 8> Reductions;
|
||||
if (!findInductionAndReductions(InnerLoop, Inductions, Reductions))
|
||||
if (!findInductionAndReductions(InnerLoop, Inductions, Reductions)) {
|
||||
DEBUG(dbgs() << "Only inner loops with induction or reduction PHI nodes "
|
||||
<< "are supported currently.\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO: Currently we handle only loops with 1 induction variable.
|
||||
if (Inductions.size() != 1) {
|
||||
|
@ -771,16 +774,25 @@ bool LoopInterchangeLegality::currentLimitations() {
|
|||
|
||||
InnerInductionVar = Inductions.pop_back_val();
|
||||
Reductions.clear();
|
||||
if (!findInductionAndReductions(OuterLoop, Inductions, Reductions))
|
||||
if (!findInductionAndReductions(OuterLoop, Inductions, Reductions)) {
|
||||
DEBUG(dbgs() << "Only outer loops with induction or reduction PHI nodes "
|
||||
<< "are supported currently.\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
// Outer loop cannot have reduction because then loops will not be tightly
|
||||
// nested.
|
||||
if (!Reductions.empty())
|
||||
if (!Reductions.empty()) {
|
||||
DEBUG(dbgs() << "Outer loops with reductions are not supported "
|
||||
<< "currently.\n");
|
||||
return true;
|
||||
}
|
||||
// TODO: Currently we handle only loops with 1 induction variable.
|
||||
if (Inductions.size() != 1)
|
||||
if (Inductions.size() != 1) {
|
||||
DEBUG(dbgs() << "Loops with more than 1 induction variables are not "
|
||||
<< "supported currently.\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO: Triangular loops are not handled for now.
|
||||
if (!isLoopStructureUnderstood(InnerInductionVar)) {
|
||||
|
@ -791,12 +803,16 @@ bool LoopInterchangeLegality::currentLimitations() {
|
|||
// TODO: We only handle LCSSA PHI's corresponding to reduction for now.
|
||||
BasicBlock *LoopExitBlock =
|
||||
getLoopLatchExitBlock(OuterLoopLatch, OuterLoopHeader);
|
||||
if (!LoopExitBlock || !containsSafePHI(LoopExitBlock, true))
|
||||
if (!LoopExitBlock || !containsSafePHI(LoopExitBlock, true)) {
|
||||
DEBUG(dbgs() << "Can only handle LCSSA PHIs in outer loops currently.\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
LoopExitBlock = getLoopLatchExitBlock(InnerLoopLatch, InnerLoopHeader);
|
||||
if (!LoopExitBlock || !containsSafePHI(LoopExitBlock, false))
|
||||
if (!LoopExitBlock || !containsSafePHI(LoopExitBlock, false)) {
|
||||
DEBUG(dbgs() << "Can only handle LCSSA PHIs in inner loops currently.\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO: Current limitation: Since we split the inner loop latch at the point
|
||||
// were induction variable is incremented (induction.next); We cannot have
|
||||
|
@ -816,8 +832,11 @@ bool LoopInterchangeLegality::currentLimitations() {
|
|||
InnerIndexVarInc =
|
||||
dyn_cast<Instruction>(InnerInductionVar->getIncomingValue(0));
|
||||
|
||||
if (!InnerIndexVarInc)
|
||||
if (!InnerIndexVarInc) {
|
||||
DEBUG(dbgs() << "Did not find an instruction to increment the induction "
|
||||
<< "variable.\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
// Since we split the inner loop latch on this induction variable. Make sure
|
||||
// we do not have any instruction between the induction variable and branch
|
||||
|
@ -827,19 +846,24 @@ bool LoopInterchangeLegality::currentLimitations() {
|
|||
for (const Instruction &I : reverse(*InnerLoopLatch)) {
|
||||
if (isa<BranchInst>(I) || isa<CmpInst>(I) || isa<TruncInst>(I))
|
||||
continue;
|
||||
|
||||
// We found an instruction. If this is not induction variable then it is not
|
||||
// safe to split this loop latch.
|
||||
if (!I.isIdenticalTo(InnerIndexVarInc))
|
||||
if (!I.isIdenticalTo(InnerIndexVarInc)) {
|
||||
DEBUG(dbgs() << "Found unsupported instructions between induction "
|
||||
<< "variable increment and branch.\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
FoundInduction = true;
|
||||
break;
|
||||
}
|
||||
// The loop latch ended and we didn't find the induction variable return as
|
||||
// current limitation.
|
||||
if (!FoundInduction)
|
||||
if (!FoundInduction) {
|
||||
DEBUG(dbgs() << "Did not find the induction variable.\n");
|
||||
return true;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue