mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-18 14:31:27 +00:00
[PM] Now that LoopInfo isn't in the Pass type hierarchy, it is much
cleaner to derive from the generic base. Thise removes a ton of boiler plate code and somewhat strange and pointless indirections. It also remove a bunch of the previously needed friend declarations. To fully remove these, I also lifted the verify logic into the generic LoopInfoBase, which seems good anyways -- it is generic and useful logic even for the machine side. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226385 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
e81cec19db
commit
5a2d01e5b8
@ -495,7 +495,6 @@ class LoopInfoBase {
|
|||||||
std::vector<LoopT *> TopLevelLoops;
|
std::vector<LoopT *> TopLevelLoops;
|
||||||
friend class LoopBase<BlockT, LoopT>;
|
friend class LoopBase<BlockT, LoopT>;
|
||||||
friend class LoopInfo;
|
friend class LoopInfo;
|
||||||
friend class LoopInfoWrapperPass;
|
|
||||||
|
|
||||||
void operator=(const LoopInfoBase &) LLVM_DELETED_FUNCTION;
|
void operator=(const LoopInfoBase &) LLVM_DELETED_FUNCTION;
|
||||||
LoopInfoBase(const LoopInfo &) LLVM_DELETED_FUNCTION;
|
LoopInfoBase(const LoopInfo &) LLVM_DELETED_FUNCTION;
|
||||||
@ -618,8 +617,9 @@ public:
|
|||||||
void Analyze(DominatorTreeBase<BlockT> &DomTree);
|
void Analyze(DominatorTreeBase<BlockT> &DomTree);
|
||||||
|
|
||||||
// Debugging
|
// Debugging
|
||||||
|
|
||||||
void print(raw_ostream &OS) const;
|
void print(raw_ostream &OS) const;
|
||||||
|
|
||||||
|
void verify() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Implementation in LoopInfoImpl.h
|
// Implementation in LoopInfoImpl.h
|
||||||
@ -627,86 +627,17 @@ public:
|
|||||||
__extension__ extern template class LoopInfoBase<BasicBlock, Loop>;
|
__extension__ extern template class LoopInfoBase<BasicBlock, Loop>;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class LoopInfo {
|
class LoopInfo : public LoopInfoBase<BasicBlock, Loop> {
|
||||||
LoopInfoBase<BasicBlock, Loop> LI;
|
typedef LoopInfoBase<BasicBlock, Loop> BaseT;
|
||||||
|
|
||||||
friend class LoopBase<BasicBlock, Loop>;
|
friend class LoopBase<BasicBlock, Loop>;
|
||||||
friend class LoopInfoWrapperPass;
|
|
||||||
|
|
||||||
void operator=(const LoopInfo &) LLVM_DELETED_FUNCTION;
|
void operator=(const LoopInfo &) LLVM_DELETED_FUNCTION;
|
||||||
LoopInfo(const LoopInfo &) LLVM_DELETED_FUNCTION;
|
LoopInfo(const LoopInfo &) LLVM_DELETED_FUNCTION;
|
||||||
public:
|
public:
|
||||||
LoopInfo() {}
|
LoopInfo() {}
|
||||||
|
|
||||||
LoopInfoBase<BasicBlock, Loop>& getBase() { return LI; }
|
// Most of the public interface is provided via LoopInfoBase.
|
||||||
|
|
||||||
/// iterator/begin/end - The interface to the top-level loops in the current
|
|
||||||
/// function.
|
|
||||||
///
|
|
||||||
typedef LoopInfoBase<BasicBlock, Loop>::iterator iterator;
|
|
||||||
typedef LoopInfoBase<BasicBlock, Loop>::reverse_iterator reverse_iterator;
|
|
||||||
inline iterator begin() const { return LI.begin(); }
|
|
||||||
inline iterator end() const { return LI.end(); }
|
|
||||||
inline reverse_iterator rbegin() const { return LI.rbegin(); }
|
|
||||||
inline reverse_iterator rend() const { return LI.rend(); }
|
|
||||||
bool empty() const { return LI.empty(); }
|
|
||||||
|
|
||||||
/// getLoopFor - Return the inner most loop that BB lives in. If a basic
|
|
||||||
/// block is in no loop (for example the entry node), null is returned.
|
|
||||||
///
|
|
||||||
inline Loop *getLoopFor(const BasicBlock *BB) const {
|
|
||||||
return LI.getLoopFor(BB);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// operator[] - same as getLoopFor...
|
|
||||||
///
|
|
||||||
inline const Loop *operator[](const BasicBlock *BB) const {
|
|
||||||
return LI.getLoopFor(BB);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// getLoopDepth - Return the loop nesting level of the specified block. A
|
|
||||||
/// depth of 0 means the block is not inside any loop.
|
|
||||||
///
|
|
||||||
inline unsigned getLoopDepth(const BasicBlock *BB) const {
|
|
||||||
return LI.getLoopDepth(BB);
|
|
||||||
}
|
|
||||||
|
|
||||||
// isLoopHeader - True if the block is a loop header node
|
|
||||||
inline bool isLoopHeader(BasicBlock *BB) const {
|
|
||||||
return LI.isLoopHeader(BB);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// removeLoop - This removes the specified top-level loop from this loop info
|
|
||||||
/// object. The loop is not deleted, as it will presumably be inserted into
|
|
||||||
/// another loop.
|
|
||||||
inline Loop *removeLoop(iterator I) { return LI.removeLoop(I); }
|
|
||||||
|
|
||||||
/// changeLoopFor - Change the top-level loop that contains BB to the
|
|
||||||
/// specified loop. This should be used by transformations that restructure
|
|
||||||
/// the loop hierarchy tree.
|
|
||||||
inline void changeLoopFor(BasicBlock *BB, Loop *L) {
|
|
||||||
LI.changeLoopFor(BB, L);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// changeTopLevelLoop - Replace the specified loop in the top-level loops
|
|
||||||
/// list with the indicated loop.
|
|
||||||
inline void changeTopLevelLoop(Loop *OldLoop, Loop *NewLoop) {
|
|
||||||
LI.changeTopLevelLoop(OldLoop, NewLoop);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// addTopLevelLoop - This adds the specified loop to the collection of
|
|
||||||
/// top-level loops.
|
|
||||||
inline void addTopLevelLoop(Loop *New) {
|
|
||||||
LI.addTopLevelLoop(New);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// removeBlock - This method completely removes BB from all data structures,
|
|
||||||
/// including all of the Loop objects it is nested in and our mapping from
|
|
||||||
/// BasicBlocks to loops.
|
|
||||||
void removeBlock(BasicBlock *BB) {
|
|
||||||
LI.removeBlock(BB);
|
|
||||||
}
|
|
||||||
|
|
||||||
void releaseMemory() { LI.releaseMemory(); }
|
|
||||||
|
|
||||||
/// updateUnloop - Update LoopInfo after removing the last backedge from a
|
/// updateUnloop - Update LoopInfo after removing the last backedge from a
|
||||||
/// loop--now the "unloop". This updates the loop forest and parent loops for
|
/// loop--now the "unloop". This updates the loop forest and parent loops for
|
||||||
|
@ -545,6 +545,25 @@ void LoopInfoBase<BlockT, LoopT>::print(raw_ostream &OS) const {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class BlockT, class LoopT>
|
||||||
|
void LoopInfoBase<BlockT, LoopT>::verify() const {
|
||||||
|
DenseSet<const LoopT*> Loops;
|
||||||
|
for (iterator I = begin(), E = end(); I != E; ++I) {
|
||||||
|
assert(!(*I)->getParentLoop() && "Top-level loop has a parent!");
|
||||||
|
(*I)->verifyLoopNest(&Loops);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify that blocks are mapped to valid loops.
|
||||||
|
#ifndef NDEBUG
|
||||||
|
for (auto &Entry : BBMap) {
|
||||||
|
BlockT *BB = Entry.first;
|
||||||
|
LoopT *L = Entry.second;
|
||||||
|
assert(Loops.count(L) && "orphaned loop");
|
||||||
|
assert(L->contains(BB) && "orphaned block");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
} // End llvm namespace
|
} // End llvm namespace
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -617,7 +617,8 @@ void LoopInfo::updateUnloop(Loop *Unloop) {
|
|||||||
if (!Unloop->getParentLoop()) {
|
if (!Unloop->getParentLoop()) {
|
||||||
// Since BBLoop had no parent, Unloop blocks are no longer in a loop.
|
// Since BBLoop had no parent, Unloop blocks are no longer in a loop.
|
||||||
for (Loop::block_iterator I = Unloop->block_begin(),
|
for (Loop::block_iterator I = Unloop->block_begin(),
|
||||||
E = Unloop->block_end(); I != E; ++I) {
|
E = Unloop->block_end();
|
||||||
|
I != E; ++I) {
|
||||||
|
|
||||||
// Don't reparent blocks in subloops.
|
// Don't reparent blocks in subloops.
|
||||||
if (getLoopFor(*I) != Unloop)
|
if (getLoopFor(*I) != Unloop)
|
||||||
@ -625,21 +626,21 @@ void LoopInfo::updateUnloop(Loop *Unloop) {
|
|||||||
|
|
||||||
// Blocks no longer have a parent but are still referenced by Unloop until
|
// Blocks no longer have a parent but are still referenced by Unloop until
|
||||||
// the Unloop object is deleted.
|
// the Unloop object is deleted.
|
||||||
LI.changeLoopFor(*I, nullptr);
|
changeLoopFor(*I, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove the loop from the top-level LoopInfo object.
|
// Remove the loop from the top-level LoopInfo object.
|
||||||
for (LoopInfo::iterator I = LI.begin();; ++I) {
|
for (iterator I = begin();; ++I) {
|
||||||
assert(I != LI.end() && "Couldn't find loop");
|
assert(I != end() && "Couldn't find loop");
|
||||||
if (*I == Unloop) {
|
if (*I == Unloop) {
|
||||||
LI.removeLoop(I);
|
removeLoop(I);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move all of the subloops to the top-level.
|
// Move all of the subloops to the top-level.
|
||||||
while (!Unloop->empty())
|
while (!Unloop->empty())
|
||||||
LI.addTopLevelLoop(Unloop->removeChildLoop(std::prev(Unloop->end())));
|
addTopLevelLoop(Unloop->removeChildLoop(std::prev(Unloop->end())));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -679,7 +680,7 @@ INITIALIZE_PASS_END(LoopInfoWrapperPass, "loops", "Natural Loop Information",
|
|||||||
|
|
||||||
bool LoopInfoWrapperPass::runOnFunction(Function &) {
|
bool LoopInfoWrapperPass::runOnFunction(Function &) {
|
||||||
releaseMemory();
|
releaseMemory();
|
||||||
LI.getBase().Analyze(getAnalysis<DominatorTreeWrapperPass>().getDomTree());
|
LI.Analyze(getAnalysis<DominatorTreeWrapperPass>().getDomTree());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -689,24 +690,8 @@ void LoopInfoWrapperPass::verifyAnalysis() const {
|
|||||||
// -verify-loop-info option can enable this. In order to perform some
|
// -verify-loop-info option can enable this. In order to perform some
|
||||||
// checking by default, LoopPass has been taught to call verifyLoop manually
|
// checking by default, LoopPass has been taught to call verifyLoop manually
|
||||||
// during loop pass sequences.
|
// during loop pass sequences.
|
||||||
|
if (VerifyLoopInfo)
|
||||||
if (!VerifyLoopInfo) return;
|
LI.verify();
|
||||||
|
|
||||||
DenseSet<const Loop*> Loops;
|
|
||||||
for (LoopInfo::iterator I = LI.begin(), E = LI.end(); I != E; ++I) {
|
|
||||||
assert(!(*I)->getParentLoop() && "Top-level loop has a parent!");
|
|
||||||
(*I)->verifyLoopNest(&Loops);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Verify that blocks are mapped to valid loops.
|
|
||||||
#ifndef NDEBUG
|
|
||||||
for (auto &Entry : LI.LI.BBMap) {
|
|
||||||
BasicBlock *BB = Entry.first;
|
|
||||||
Loop *L = Entry.second;
|
|
||||||
assert(Loops.count(L) && "orphaned loop");
|
|
||||||
assert(L->contains(BB) && "orphaned block");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoopInfoWrapperPass::getAnalysisUsage(AnalysisUsage &AU) const {
|
void LoopInfoWrapperPass::getAnalysisUsage(AnalysisUsage &AU) const {
|
||||||
@ -715,7 +700,7 @@ void LoopInfoWrapperPass::getAnalysisUsage(AnalysisUsage &AU) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void LoopInfoWrapperPass::print(raw_ostream &OS, const Module *) const {
|
void LoopInfoWrapperPass::print(raw_ostream &OS, const Module *) const {
|
||||||
LI.LI.print(OS);
|
LI.print(OS);
|
||||||
}
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
@ -982,9 +982,8 @@ void LoopConstrainer::addToParentLoopIfNeeded(IteratorTy Begin,
|
|||||||
if (!ParentLoop)
|
if (!ParentLoop)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto &LoopInfoBase = OriginalLoopInfo.getBase();
|
|
||||||
for (; Begin != End; Begin++)
|
for (; Begin != End; Begin++)
|
||||||
ParentLoop->addBasicBlockToLoop(*Begin, LoopInfoBase);
|
ParentLoop->addBasicBlockToLoop(*Begin, OriginalLoopInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LoopConstrainer::run() {
|
bool LoopConstrainer::run() {
|
||||||
|
@ -675,7 +675,7 @@ static Loop *CloneLoop(Loop *L, Loop *PL, ValueToValueMapTy &VM,
|
|||||||
for (Loop::block_iterator I = L->block_begin(), E = L->block_end();
|
for (Loop::block_iterator I = L->block_begin(), E = L->block_end();
|
||||||
I != E; ++I)
|
I != E; ++I)
|
||||||
if (LI->getLoopFor(*I) == L)
|
if (LI->getLoopFor(*I) == L)
|
||||||
New->addBasicBlockToLoop(cast<BasicBlock>(VM[*I]), LI->getBase());
|
New->addBasicBlockToLoop(cast<BasicBlock>(VM[*I]), *LI);
|
||||||
|
|
||||||
// Add all of the subloops to the new loop.
|
// Add all of the subloops to the new loop.
|
||||||
for (Loop::iterator I = L->begin(), E = L->end(); I != E; ++I)
|
for (Loop::iterator I = L->begin(), E = L->end(); I != E; ++I)
|
||||||
@ -850,14 +850,14 @@ void LoopUnswitch::UnswitchNontrivialCondition(Value *LIC, Constant *Val,
|
|||||||
if (ParentLoop) {
|
if (ParentLoop) {
|
||||||
// Make sure to add the cloned preheader and exit blocks to the parent loop
|
// Make sure to add the cloned preheader and exit blocks to the parent loop
|
||||||
// as well.
|
// as well.
|
||||||
ParentLoop->addBasicBlockToLoop(NewBlocks[0], LI->getBase());
|
ParentLoop->addBasicBlockToLoop(NewBlocks[0], *LI);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned i = 0, e = ExitBlocks.size(); i != e; ++i) {
|
for (unsigned i = 0, e = ExitBlocks.size(); i != e; ++i) {
|
||||||
BasicBlock *NewExit = cast<BasicBlock>(VMap[ExitBlocks[i]]);
|
BasicBlock *NewExit = cast<BasicBlock>(VMap[ExitBlocks[i]]);
|
||||||
// The new exit block should be in the same loop as the old one.
|
// The new exit block should be in the same loop as the old one.
|
||||||
if (Loop *ExitBBLoop = LI->getLoopFor(ExitBlocks[i]))
|
if (Loop *ExitBBLoop = LI->getLoopFor(ExitBlocks[i]))
|
||||||
ExitBBLoop->addBasicBlockToLoop(NewExit, LI->getBase());
|
ExitBBLoop->addBasicBlockToLoop(NewExit, *LI);
|
||||||
|
|
||||||
assert(NewExit->getTerminator()->getNumSuccessors() == 1 &&
|
assert(NewExit->getTerminator()->getNumSuccessors() == 1 &&
|
||||||
"Exit block should have been split to have one successor!");
|
"Exit block should have been split to have one successor!");
|
||||||
|
@ -293,7 +293,7 @@ BasicBlock *llvm::SplitBlock(BasicBlock *Old, Instruction *SplitPt, Pass *P) {
|
|||||||
if (auto *LIWP = P->getAnalysisIfAvailable<LoopInfoWrapperPass>()) {
|
if (auto *LIWP = P->getAnalysisIfAvailable<LoopInfoWrapperPass>()) {
|
||||||
LoopInfo &LI = LIWP->getLoopInfo();
|
LoopInfo &LI = LIWP->getLoopInfo();
|
||||||
if (Loop *L = LI.getLoopFor(Old))
|
if (Loop *L = LI.getLoopFor(Old))
|
||||||
L->addBasicBlockToLoop(New, LI.getBase());
|
L->addBasicBlockToLoop(New, LI);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DominatorTreeWrapperPass *DTWP =
|
if (DominatorTreeWrapperPass *DTWP =
|
||||||
@ -385,9 +385,9 @@ static void UpdateAnalysisInformation(BasicBlock *OldBB, BasicBlock *NewBB,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (InnermostPredLoop)
|
if (InnermostPredLoop)
|
||||||
InnermostPredLoop->addBasicBlockToLoop(NewBB, LI->getBase());
|
InnermostPredLoop->addBasicBlockToLoop(NewBB, *LI);
|
||||||
} else {
|
} else {
|
||||||
L->addBasicBlockToLoop(NewBB, LI->getBase());
|
L->addBasicBlockToLoop(NewBB, *LI);
|
||||||
if (SplitMakesNewLoopHeader)
|
if (SplitMakesNewLoopHeader)
|
||||||
L->moveToHeader(NewBB);
|
L->moveToHeader(NewBB);
|
||||||
}
|
}
|
||||||
|
@ -269,13 +269,13 @@ BasicBlock *llvm::SplitCriticalEdge(TerminatorInst *TI, unsigned SuccNum,
|
|||||||
if (Loop *DestLoop = LI->getLoopFor(DestBB)) {
|
if (Loop *DestLoop = LI->getLoopFor(DestBB)) {
|
||||||
if (TIL == DestLoop) {
|
if (TIL == DestLoop) {
|
||||||
// Both in the same loop, the NewBB joins loop.
|
// Both in the same loop, the NewBB joins loop.
|
||||||
DestLoop->addBasicBlockToLoop(NewBB, LI->getBase());
|
DestLoop->addBasicBlockToLoop(NewBB, *LI);
|
||||||
} else if (TIL->contains(DestLoop)) {
|
} else if (TIL->contains(DestLoop)) {
|
||||||
// Edge from an outer loop to an inner loop. Add to the outer loop.
|
// Edge from an outer loop to an inner loop. Add to the outer loop.
|
||||||
TIL->addBasicBlockToLoop(NewBB, LI->getBase());
|
TIL->addBasicBlockToLoop(NewBB, *LI);
|
||||||
} else if (DestLoop->contains(TIL)) {
|
} else if (DestLoop->contains(TIL)) {
|
||||||
// Edge from an inner loop to an outer loop. Add to the outer loop.
|
// Edge from an inner loop to an outer loop. Add to the outer loop.
|
||||||
DestLoop->addBasicBlockToLoop(NewBB, LI->getBase());
|
DestLoop->addBasicBlockToLoop(NewBB, *LI);
|
||||||
} else {
|
} else {
|
||||||
// Edge from two loops with no containment relation. Because these
|
// Edge from two loops with no containment relation. Because these
|
||||||
// are natural loops, we know that the destination block must be the
|
// are natural loops, we know that the destination block must be the
|
||||||
@ -284,7 +284,7 @@ BasicBlock *llvm::SplitCriticalEdge(TerminatorInst *TI, unsigned SuccNum,
|
|||||||
assert(DestLoop->getHeader() == DestBB &&
|
assert(DestLoop->getHeader() == DestBB &&
|
||||||
"Should not create irreducible loops!");
|
"Should not create irreducible loops!");
|
||||||
if (Loop *P = DestLoop->getParentLoop())
|
if (Loop *P = DestLoop->getParentLoop())
|
||||||
P->addBasicBlockToLoop(NewBB, LI->getBase());
|
P->addBasicBlockToLoop(NewBB, *LI);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If TIBB is in a loop and DestBB is outside of that loop, we may need
|
// If TIBB is in a loop and DestBB is outside of that loop, we may need
|
||||||
|
@ -460,7 +460,7 @@ static BasicBlock *insertUniqueBackedgeBlock(Loop *L, BasicBlock *Preheader,
|
|||||||
|
|
||||||
// Update Loop Information - we know that this block is now in the current
|
// Update Loop Information - we know that this block is now in the current
|
||||||
// loop and all parent loops.
|
// loop and all parent loops.
|
||||||
L->addBasicBlockToLoop(BEBlock, LI->getBase());
|
L->addBasicBlockToLoop(BEBlock, *LI);
|
||||||
|
|
||||||
// Update dominator information
|
// Update dominator information
|
||||||
DT->splitBlock(BEBlock);
|
DT->splitBlock(BEBlock);
|
||||||
|
@ -311,7 +311,7 @@ bool llvm::UnrollLoop(Loop *L, unsigned Count, unsigned TripCount,
|
|||||||
// Tell LI about New.
|
// Tell LI about New.
|
||||||
if (*BB == Header) {
|
if (*BB == Header) {
|
||||||
assert(LI->getLoopFor(*BB) == L && "Header should not be in a sub-loop");
|
assert(LI->getLoopFor(*BB) == L && "Header should not be in a sub-loop");
|
||||||
L->addBasicBlockToLoop(New, LI->getBase());
|
L->addBasicBlockToLoop(New, *LI);
|
||||||
} else {
|
} else {
|
||||||
// Figure out which loop New is in.
|
// Figure out which loop New is in.
|
||||||
const Loop *OldLoop = LI->getLoopFor(*BB);
|
const Loop *OldLoop = LI->getLoopFor(*BB);
|
||||||
@ -333,7 +333,7 @@ bool llvm::UnrollLoop(Loop *L, unsigned Count, unsigned TripCount,
|
|||||||
if (SE)
|
if (SE)
|
||||||
SE->forgetLoop(OldLoop);
|
SE->forgetLoop(OldLoop);
|
||||||
}
|
}
|
||||||
NewLoop->addBasicBlockToLoop(New, LI->getBase());
|
NewLoop->addBasicBlockToLoop(New, *LI);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*BB == Header)
|
if (*BB == Header)
|
||||||
|
@ -160,9 +160,9 @@ static void CloneLoopBlocks(Loop *L, Value *NewIter, const bool UnrollProlog,
|
|||||||
NewBlocks.push_back(NewBB);
|
NewBlocks.push_back(NewBB);
|
||||||
|
|
||||||
if (NewLoop)
|
if (NewLoop)
|
||||||
NewLoop->addBasicBlockToLoop(NewBB, LI->getBase());
|
NewLoop->addBasicBlockToLoop(NewBB, *LI);
|
||||||
else if (ParentLoop)
|
else if (ParentLoop)
|
||||||
ParentLoop->addBasicBlockToLoop(NewBB, LI->getBase());
|
ParentLoop->addBasicBlockToLoop(NewBB, *LI);
|
||||||
|
|
||||||
VMap[*BB] = NewBB;
|
VMap[*BB] = NewBB;
|
||||||
if (Header == *BB) {
|
if (Header == *BB) {
|
||||||
|
@ -1991,7 +1991,7 @@ void InnerLoopVectorizer::scalarizeInstruction(Instruction *Instr, bool IfPredic
|
|||||||
Cmp = Builder.CreateICmp(ICmpInst::ICMP_EQ, Cmp, ConstantInt::get(Cmp->getType(), 1));
|
Cmp = Builder.CreateICmp(ICmpInst::ICMP_EQ, Cmp, ConstantInt::get(Cmp->getType(), 1));
|
||||||
CondBlock = IfBlock->splitBasicBlock(InsertPt, "cond.store");
|
CondBlock = IfBlock->splitBasicBlock(InsertPt, "cond.store");
|
||||||
LoopVectorBody.push_back(CondBlock);
|
LoopVectorBody.push_back(CondBlock);
|
||||||
VectorLp->addBasicBlockToLoop(CondBlock, LI->getBase());
|
VectorLp->addBasicBlockToLoop(CondBlock, *LI);
|
||||||
// Update Builder with newly created basic block.
|
// Update Builder with newly created basic block.
|
||||||
Builder.SetInsertPoint(InsertPt);
|
Builder.SetInsertPoint(InsertPt);
|
||||||
}
|
}
|
||||||
@ -2020,7 +2020,7 @@ void InnerLoopVectorizer::scalarizeInstruction(Instruction *Instr, bool IfPredic
|
|||||||
if (IfPredicateStore) {
|
if (IfPredicateStore) {
|
||||||
BasicBlock *NewIfBlock = CondBlock->splitBasicBlock(InsertPt, "else");
|
BasicBlock *NewIfBlock = CondBlock->splitBasicBlock(InsertPt, "else");
|
||||||
LoopVectorBody.push_back(NewIfBlock);
|
LoopVectorBody.push_back(NewIfBlock);
|
||||||
VectorLp->addBasicBlockToLoop(NewIfBlock, LI->getBase());
|
VectorLp->addBasicBlockToLoop(NewIfBlock, *LI);
|
||||||
Builder.SetInsertPoint(InsertPt);
|
Builder.SetInsertPoint(InsertPt);
|
||||||
Instruction *OldBr = IfBlock->getTerminator();
|
Instruction *OldBr = IfBlock->getTerminator();
|
||||||
BranchInst::Create(CondBlock, NewIfBlock, Cmp, OldBr);
|
BranchInst::Create(CondBlock, NewIfBlock, Cmp, OldBr);
|
||||||
@ -2298,13 +2298,13 @@ void InnerLoopVectorizer::createEmptyLoop() {
|
|||||||
// before calling any utilities such as SCEV that require valid LoopInfo.
|
// before calling any utilities such as SCEV that require valid LoopInfo.
|
||||||
if (ParentLoop) {
|
if (ParentLoop) {
|
||||||
ParentLoop->addChildLoop(Lp);
|
ParentLoop->addChildLoop(Lp);
|
||||||
ParentLoop->addBasicBlockToLoop(ScalarPH, LI->getBase());
|
ParentLoop->addBasicBlockToLoop(ScalarPH, *LI);
|
||||||
ParentLoop->addBasicBlockToLoop(VectorPH, LI->getBase());
|
ParentLoop->addBasicBlockToLoop(VectorPH, *LI);
|
||||||
ParentLoop->addBasicBlockToLoop(MiddleBlock, LI->getBase());
|
ParentLoop->addBasicBlockToLoop(MiddleBlock, *LI);
|
||||||
} else {
|
} else {
|
||||||
LI->addTopLevelLoop(Lp);
|
LI->addTopLevelLoop(Lp);
|
||||||
}
|
}
|
||||||
Lp->addBasicBlockToLoop(VecBody, LI->getBase());
|
Lp->addBasicBlockToLoop(VecBody, *LI);
|
||||||
|
|
||||||
// Use this IR builder to create the loop instructions (Phi, Br, Cmp)
|
// Use this IR builder to create the loop instructions (Phi, Br, Cmp)
|
||||||
// inside the loop.
|
// inside the loop.
|
||||||
@ -2359,7 +2359,7 @@ void InnerLoopVectorizer::createEmptyLoop() {
|
|||||||
BasicBlock *CheckBlock =
|
BasicBlock *CheckBlock =
|
||||||
LastBypassBlock->splitBasicBlock(PastOverflowCheck, "overflow.checked");
|
LastBypassBlock->splitBasicBlock(PastOverflowCheck, "overflow.checked");
|
||||||
if (ParentLoop)
|
if (ParentLoop)
|
||||||
ParentLoop->addBasicBlockToLoop(CheckBlock, LI->getBase());
|
ParentLoop->addBasicBlockToLoop(CheckBlock, *LI);
|
||||||
LoopBypassBlocks.push_back(CheckBlock);
|
LoopBypassBlocks.push_back(CheckBlock);
|
||||||
Instruction *OldTerm = LastBypassBlock->getTerminator();
|
Instruction *OldTerm = LastBypassBlock->getTerminator();
|
||||||
BranchInst::Create(ScalarPH, CheckBlock, CheckBCOverflow, OldTerm);
|
BranchInst::Create(ScalarPH, CheckBlock, CheckBCOverflow, OldTerm);
|
||||||
@ -2379,7 +2379,7 @@ void InnerLoopVectorizer::createEmptyLoop() {
|
|||||||
BasicBlock *CheckBlock =
|
BasicBlock *CheckBlock =
|
||||||
LastBypassBlock->splitBasicBlock(FirstCheckInst, "vector.stridecheck");
|
LastBypassBlock->splitBasicBlock(FirstCheckInst, "vector.stridecheck");
|
||||||
if (ParentLoop)
|
if (ParentLoop)
|
||||||
ParentLoop->addBasicBlockToLoop(CheckBlock, LI->getBase());
|
ParentLoop->addBasicBlockToLoop(CheckBlock, *LI);
|
||||||
LoopBypassBlocks.push_back(CheckBlock);
|
LoopBypassBlocks.push_back(CheckBlock);
|
||||||
|
|
||||||
// Replace the branch into the memory check block with a conditional branch
|
// Replace the branch into the memory check block with a conditional branch
|
||||||
@ -2403,7 +2403,7 @@ void InnerLoopVectorizer::createEmptyLoop() {
|
|||||||
BasicBlock *CheckBlock =
|
BasicBlock *CheckBlock =
|
||||||
LastBypassBlock->splitBasicBlock(MemRuntimeCheck, "vector.memcheck");
|
LastBypassBlock->splitBasicBlock(MemRuntimeCheck, "vector.memcheck");
|
||||||
if (ParentLoop)
|
if (ParentLoop)
|
||||||
ParentLoop->addBasicBlockToLoop(CheckBlock, LI->getBase());
|
ParentLoop->addBasicBlockToLoop(CheckBlock, *LI);
|
||||||
LoopBypassBlocks.push_back(CheckBlock);
|
LoopBypassBlocks.push_back(CheckBlock);
|
||||||
|
|
||||||
// Replace the branch into the memory check block with a conditional branch
|
// Replace the branch into the memory check block with a conditional branch
|
||||||
@ -6258,7 +6258,7 @@ void InnerLoopUnroller::scalarizeInstruction(Instruction *Instr,
|
|||||||
ConstantInt::get(Cond[Part]->getType(), 1));
|
ConstantInt::get(Cond[Part]->getType(), 1));
|
||||||
CondBlock = IfBlock->splitBasicBlock(InsertPt, "cond.store");
|
CondBlock = IfBlock->splitBasicBlock(InsertPt, "cond.store");
|
||||||
LoopVectorBody.push_back(CondBlock);
|
LoopVectorBody.push_back(CondBlock);
|
||||||
VectorLp->addBasicBlockToLoop(CondBlock, LI->getBase());
|
VectorLp->addBasicBlockToLoop(CondBlock, *LI);
|
||||||
// Update Builder with newly created basic block.
|
// Update Builder with newly created basic block.
|
||||||
Builder.SetInsertPoint(InsertPt);
|
Builder.SetInsertPoint(InsertPt);
|
||||||
}
|
}
|
||||||
@ -6284,7 +6284,7 @@ void InnerLoopUnroller::scalarizeInstruction(Instruction *Instr,
|
|||||||
if (IfPredicateStore) {
|
if (IfPredicateStore) {
|
||||||
BasicBlock *NewIfBlock = CondBlock->splitBasicBlock(InsertPt, "else");
|
BasicBlock *NewIfBlock = CondBlock->splitBasicBlock(InsertPt, "else");
|
||||||
LoopVectorBody.push_back(NewIfBlock);
|
LoopVectorBody.push_back(NewIfBlock);
|
||||||
VectorLp->addBasicBlockToLoop(NewIfBlock, LI->getBase());
|
VectorLp->addBasicBlockToLoop(NewIfBlock, *LI);
|
||||||
Builder.SetInsertPoint(InsertPt);
|
Builder.SetInsertPoint(InsertPt);
|
||||||
Instruction *OldBr = IfBlock->getTerminator();
|
Instruction *OldBr = IfBlock->getTerminator();
|
||||||
BranchInst::Create(CondBlock, NewIfBlock, Cmp, OldBr);
|
BranchInst::Create(CondBlock, NewIfBlock, Cmp, OldBr);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user