[llvm] r324881 - [LoopInterchange] Simplify splitInnerLoopHeader logic (NFC).
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 12 03:10:58 PST 2018
Author: fhahn
Date: Mon Feb 12 03:10:58 2018
New Revision: 324881
URL: http://llvm.org/viewvc/llvm-project?rev=324881&view=rev
Log:
[LoopInterchange] Simplify splitInnerLoopHeader logic (NFC).
We can use SplitBlock for both cases, which makes the code slightly
simpler and updates both LoopInfo and the dominator tree.
Modified:
llvm/trunk/lib/Transforms/Scalar/LoopInterchange.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/LoopInterchange.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopInterchange.cpp?rev=324881&r1=324880&r2=324881&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopInterchange.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopInterchange.cpp Mon Feb 12 03:10:58 2018
@@ -1222,17 +1222,12 @@ void LoopInterchangeTransform::splitInne
// stay in the innerloop body.
BasicBlock *InnerLoopHeader = InnerLoop->getHeader();
BasicBlock *InnerLoopPreHeader = InnerLoop->getLoopPreheader();
+ SplitBlock(InnerLoopHeader, InnerLoopHeader->getFirstNonPHI(), DT, LI);
if (InnerLoopHasReduction) {
- // Note: The induction PHI must be the first PHI for this to work
- BasicBlock *New = InnerLoopHeader->splitBasicBlock(
- ++(InnerLoopHeader->begin()), InnerLoopHeader->getName() + ".split");
- if (LI)
- if (Loop *L = LI->getLoopFor(InnerLoopHeader))
- L->addBasicBlockToLoop(New, *LI);
-
- // Adjust Reduction PHI's in the block.
+ // Adjust Reduction PHI's in the block. The induction PHI must be the first
+ // PHI in InnerLoopHeader for this to work.
SmallVector<PHINode *, 8> PHIVec;
- for (auto I = New->begin(); isa<PHINode>(I); ++I) {
+ for (auto I = std::next(InnerLoopHeader->begin()); isa<PHINode>(I); ++I) {
PHINode *PHI = dyn_cast<PHINode>(I);
Value *V = PHI->getIncomingValueForBlock(InnerLoopPreHeader);
PHI->replaceAllUsesWith(V);
@@ -1241,8 +1236,6 @@ void LoopInterchangeTransform::splitInne
for (PHINode *P : PHIVec) {
P->eraseFromParent();
}
- } else {
- SplitBlock(InnerLoopHeader, InnerLoopHeader->getFirstNonPHI(), DT, LI);
}
DEBUG(dbgs() << "Output of splitInnerLoopHeader InnerLoopHeaderSucc & "
More information about the llvm-commits
mailing list