47#define DEBUG_TYPE "loop-unroll"
50 "Number of loops unrolled with run-time trip counts");
53 cl::desc(
"Allow runtime unrolling for loops with multiple exits, when "
54 "epilog is generated"));
57 cl::desc(
"Assume the non latch exit block to be predictable"));
91 assert(Latch &&
"Loop must have a latch");
92 BasicBlock *PrologLatch = cast<BasicBlock>(VMap[Latch]);
100 for (
PHINode &PN : Succ->phis()) {
112 if (L->contains(&PN)) {
114 NewPN->
addIncoming(PN.getIncomingValueForBlock(NewPreHeader),
121 Value *V = PN.getIncomingValueForBlock(Latch);
123 if (L->contains(
I)) {
134 if (L->contains(&PN))
135 PN.setIncomingValueForBlock(NewPreHeader, NewPN);
137 PN.addIncoming(NewPN, PrologExit);
151 nullptr, PreserveLCSSA);
159 assert(Count != 0 &&
"nonsensical Count!");
170 nullptr, PreserveLCSSA);
172 B.CreateCondBr(BrLoopExit, OriginalLoopLatchExit, NewPreHeader);
200 assert(Latch &&
"Loop must have a latch");
201 BasicBlock *EpilogLatch = cast<BasicBlock>(VMap[Latch]);
233 assert(PN.hasOneUse() &&
"The phi should have 1 use");
234 PHINode *EpilogPN = cast<PHINode>(PN.use_begin()->getUser());
235 assert(EpilogPN->
getParent() == Exit &&
"EpilogPN should be in Exit block");
241 Value *V = PN.getIncomingValueForBlock(Latch);
243 if (
I && L->contains(
I))
251 "EpilogPN should have EpilogPreHeader incoming block");
267 if (!L->contains(Succ))
269 for (
PHINode &PN : Succ->phis()) {
275 NewPN->
addIncoming(PN.getIncomingValueForBlock(NewPreHeader), PreHeader);
277 NewPN->
addIncoming(PN.getIncomingValueForBlock(Latch), Latch);
281 PHINode *VPN = cast<PHINode>(VMap[&PN]);
288 Value *BrLoopExit =
B.CreateIsNotNull(ModVal,
"lcmp.mod");
289 assert(Exit &&
"Loop must have a single exit block only");
295 B.CreateCondBr(BrLoopExit, EpilogPreHeader, Exit);
316 const bool UnrollRemainder,
319 std::vector<BasicBlock *> &NewBlocks,
LoopBlocksDFS &LoopBlocks,
321 StringRef suffix = UseEpilogRemainder ?
"epil" :
"prol";
327 Loop *ParentLoop = L->getParentLoop();
329 NewLoops[ParentLoop] = ParentLoop;
335 NewBlocks.push_back(NewBB);
353 DT->
addNewBlock(NewBB, cast<BasicBlock>(VMap[IDomBB]));
359 VMap.
erase((*BB)->getTerminator());
363 BasicBlock *FirstLoopBB = cast<BasicBlock>(VMap[Header]);
373 Builder.CreateCondBr(IdxCmp, FirstLoopBB, InsertBot);
383 PHINode *NewPHI = cast<PHINode>(VMap[&*
I]);
386 BasicBlock *NewLatch = cast<BasicBlock>(VMap[Latch]);
394 Loop *NewLoop = NewLoops[L];
395 assert(NewLoop &&
"L should have been cloned");
422 bool UseEpilogRemainder) {
444 L->getExitingBlocks(ExitingBlocks);
445 if (ExitingBlocks.
size() > 2)
449 if (OtherExits.
size() == 0)
458 return (OtherExits.
size() == 1 &&
460 OtherExits[0]->getTerminatingDeoptimizeCall()));
481 uint64_t BackEdgeWeight = (UnrollFactor - 1) * ExitWeight;
484 auto *RemainderLatchBR = cast<BranchInst>(Latch->
getTerminator());
485 unsigned HeaderIdx = (RemainderLatchBR->getSuccessor(0) == Header ? 0 : 1);
486 MDBuilder MDB(RemainderLatchBR->getContext());
490 RemainderLatchBR->setMetadata(LLVMContext::MD_prof, WeightNode);
499 Value *TripCount,
unsigned Count) {
511 return B.CreateAnd(TripCount, Count - 1,
"xtraiter");
516 Value *ModValTmp =
B.CreateURem(BECount, CountC);
517 Value *ModValAdd =
B.CreateAdd(ModValTmp,
521 return B.CreateURem(ModValAdd, CountC,
"xtraiter");
564 Loop *L,
unsigned Count,
bool AllowExpensiveTripCount,
565 bool UseEpilogRemainder,
bool UnrollRemainder,
bool ForgetAllSCEV,
570 LLVM_DEBUG(UseEpilogRemainder ?
dbgs() <<
"Using epilog remainder.\n"
571 :
dbgs() <<
"Using prolog remainder.\n");
574 if (!L->isLoopSimplifyForm()) {
589 <<
"Loop latch not terminated by a conditional branch.\n");
593 unsigned ExitIndex = LatchBR->
getSuccessor(0) == Header ? 1 : 0;
596 if (L->contains(LatchExit)) {
601 <<
"One of the loop latch successors must be the exit block.\n");
607 L->getUniqueNonLatchExitBlocks(OtherExits);
610 if (!L->getExitingBlock() || OtherExits.
size()) {
617 UseEpilogRemainder)) {
620 <<
"Multiple exit/exiting blocks in loop and multi-exit unrolling not "
636 if (isa<SCEVCouldNotCompute>(BECountSC)) {
641 unsigned BEWidth = cast<IntegerType>(BECountSC->
getType())->getBitWidth();
645 const SCEV *TripCountSC =
647 if (isa<SCEVCouldNotCompute>(TripCountSC)) {
652 BasicBlock *PreHeader = L->getLoopPreheader();
654 const DataLayout &
DL = Header->getModule()->getDataLayout();
656 if (!AllowExpensiveTripCount &&
659 LLVM_DEBUG(
dbgs() <<
"High cost for expanding trip count scev!\n");
665 if (
Log2_32(Count) > BEWidth) {
668 <<
"Count failed constraint on overflow trip count calculation.\n");
686 if (UseEpilogRemainder) {
693 nullptr, PreserveLCSSA);
698 NewExitTerminator->
setDebugLoc(Header->getTerminator()->getDebugLoc());
700 EpilogPreHeader =
SplitBlock(NewExit, NewExitTerminator, DT, LI);
701 EpilogPreHeader->
setName(Header->getName() +
".epil.preheader");
709 if (
auto *ParentL = L->getParentLoop())
710 if (LI->getLoopFor(LatchExit) != ParentL) {
711 LI->removeBlock(NewExit);
712 ParentL->addBasicBlockToLoop(NewExit, *LI);
713 LI->removeBlock(EpilogPreHeader);
714 ParentL->addBasicBlockToLoop(EpilogPreHeader, *LI);
720 PrologPreHeader =
SplitEdge(PreHeader, Header, DT, LI);
721 PrologPreHeader->
setName(Header->getName() +
".prol.preheader");
724 PrologExit->
setName(Header->getName() +
".prol.loopexit");
758 TripCount =
B.CreateFreeze(TripCount);
771 UseEpilogRemainder ?
B.CreateICmpULT(BECount,
774 B.CreateIsNotNull(ModVal,
"lcmp.mod");
775 BasicBlock *RemainderLoop = UseEpilogRemainder ? NewExit : PrologPreHeader;
776 BasicBlock *UnrollingLoop = UseEpilogRemainder ? NewPreHeader : PrologExit;
778 B.CreateCondBr(BranchVal, RemainderLoop, UnrollingLoop);
781 if (UseEpilogRemainder)
797 std::vector<BasicBlock *> NewBlocks;
803 BasicBlock *InsertBot = UseEpilogRemainder ? LatchExit : PrologExit;
804 BasicBlock *InsertTop = UseEpilogRemainder ? EpilogPreHeader : PrologPreHeader;
806 L, ModVal, UseEpilogRemainder, UnrollRemainder, InsertTop, InsertBot,
807 NewPreHeader, NewBlocks, LoopBlocks, VMap, DT, LI);
811 if (remainderLoop && !UnrollRemainder)
815 F->splice(InsertBot->
getIterator(),
F, NewBlocks[0]->getIterator(),
F->end());
821 for (
auto *BB : OtherExits) {
825 for (
PHINode &PN : BB->phis()) {
826 unsigned oldNumOperands = PN.getNumIncomingValues();
829 for (
unsigned i = 0; i < oldNumOperands; i++){
830 auto *PredBB =PN.getIncomingBlock(i);
834 if (!L->contains(PredBB))
839 auto *V = PN.getIncomingValue(i);
843 PN.addIncoming(V, cast<BasicBlock>(VMap[PredBB]));
846#if defined(EXPENSIVE_CHECKS) && !defined(NDEBUG)
849 "Breaks the definition of dedicated exits!");
860 if (DT && !L->getExitingBlock()) {
866 for (
auto *BB : L->blocks()) {
867 auto *DomNodeBB = DT->
getNode(BB);
868 for (
auto *DomChild : DomNodeBB->children()) {
869 auto *DomChildBB = DomChild->
getBlock();
874 for (
auto *BB : ChildrenToUpdate)
902 if (UseEpilogRemainder) {
905 ConnectEpilog(L, ModVal, NewExit, LatchExit, PreHeader, EpilogPreHeader,
906 NewPreHeader, VMap, DT, LI, PreserveLCSSA, *SE);
916 Header->getFirstNonPHI());
921 auto Pred = LatchBR->
getSuccessor(0) == Header ? ICmpInst::ICMP_NE : ICmpInst::ICMP_EQ;
929 ConnectProlog(L, BECount, Count, PrologExit, LatchExit, PreHeader,
930 NewPreHeader, VMap, DT, LI, PreserveLCSSA, *SE);
938#if defined(EXPENSIVE_CHECKS) && !defined(NDEBUG)
940 assert(DT->
verify(DominatorTree::VerificationLevel::Full));
946 if (Count == 2 && DT && LI && SE) {
954 remainderLoop =
nullptr;
957 const DataLayout &
DL = L->getHeader()->getModule()->getDataLayout();
963 Inst.replaceAllUsesWith(V);
975 assert(ExitBB &&
"required after breaking cond br backedge");
983 if (OtherExits.
size() > 0) {
993 auto UnrollResult = LoopUnrollResult::Unmodified;
994 if (remainderLoop && UnrollRemainder) {
998 { Count - 1,
false,
false,
1000 false, ForgetAllSCEV},
1001 LI, SE, DT, AC,
TTI,
nullptr, PreserveLCSSA);
1004 if (ResultLoop && UnrollResult != LoopUnrollResult::FullyUnrolled)
1005 *ResultLoop = remainderLoop;
1006 NumRuntimeUnrolled++;
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static bool canProfitablyUnrollMultiExitLoop(Loop *L, SmallVectorImpl< BasicBlock * > &OtherExits, BasicBlock *LatchExit, bool UseEpilogRemainder)
Returns true if we can profitably unroll the multi-exit loop L.
static Loop * CloneLoopBlocks(Loop *L, Value *NewIter, const bool UseEpilogRemainder, const bool UnrollRemainder, BasicBlock *InsertTop, BasicBlock *InsertBot, BasicBlock *Preheader, std::vector< BasicBlock * > &NewBlocks, LoopBlocksDFS &LoopBlocks, ValueToValueMapTy &VMap, DominatorTree *DT, LoopInfo *LI)
Create a clone of the blocks in a loop and connect them together.
static Value * CreateTripRemainder(IRBuilder<> &B, Value *BECount, Value *TripCount, unsigned Count)
Calculate ModVal = (BECount + 1) % Count on the abstract integer domain accounting for the possibilit...
static cl::opt< bool > UnrollRuntimeOtherExitPredictable("unroll-runtime-other-exit-predictable", cl::init(false), cl::Hidden, cl::desc("Assume the non latch exit block to be predictable"))
static void updateLatchBranchWeightsForRemainderLoop(Loop *OrigLoop, Loop *RemainderLoop, uint64_t UnrollFactor)
static cl::opt< bool > UnrollRuntimeMultiExit("unroll-runtime-multi-exit", cl::init(false), cl::Hidden, cl::desc("Allow runtime unrolling for loops with multiple exits, when " "epilog is generated"))
static void ConnectEpilog(Loop *L, Value *ModVal, BasicBlock *NewExit, BasicBlock *Exit, BasicBlock *PreHeader, BasicBlock *EpilogPreHeader, BasicBlock *NewPreHeader, ValueToValueMapTy &VMap, DominatorTree *DT, LoopInfo *LI, bool PreserveLCSSA, ScalarEvolution &SE)
Connect the unrolling epilog code to the original loop.
static void ConnectProlog(Loop *L, Value *BECount, unsigned Count, BasicBlock *PrologExit, BasicBlock *OriginalLoopLatchExit, BasicBlock *PreHeader, BasicBlock *NewPreHeader, ValueToValueMapTy &VMap, DominatorTree *DT, LoopInfo *LI, bool PreserveLCSSA, ScalarEvolution &SE)
Connect the unrolling prolog code to the original loop.
Module.h This file contains the declarations for the Module class.
This file contains the declarations for profiling metadata utility functions.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
A cache of @llvm.assume calls within a function.
LLVM Basic Block Representation.
iterator_range< const_phi_iterator > phis() const
Returns a range that iterates over the phis in the basic block.
const Instruction * getFirstNonPHI() const
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
const BasicBlock * getSingleSuccessor() const
Return the successor of this block if it has a single successor.
InstListType::iterator iterator
Instruction iterators...
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
Conditional or Unconditional Branch instruction.
void setCondition(Value *V)
BasicBlock * getSuccessor(unsigned i) const
bool isUnconditional() const
static Constant * get(Type *Ty, uint64_t V, bool IsSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
This is an important base class in LLVM.
A parsed version of the target data layout string in and methods for querying it.
DomTreeNodeBase * getIDom() const
bool verify(VerificationLevel VL=VerificationLevel::Full) const
verify - checks if the tree is correct.
void changeImmediateDominator(DomTreeNodeBase< NodeT > *N, DomTreeNodeBase< NodeT > *NewIDom)
changeImmediateDominator - This method is used to update the dominator tree information when a node's...
DomTreeNodeBase< NodeT > * addNewBlock(NodeT *BB, NodeT *DomBB)
Add a new node to the dominator tree information.
DomTreeNodeBase< NodeT > * getNode(const NodeT *BB) const
getNode - return the (Post)DominatorTree node for the specified basic block.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
Instruction * findNearestCommonDominator(Instruction *I1, Instruction *I2) const
Find the nearest instruction I that dominates both I1 and I2, in the sense that a result produced bef...
Value * CreateSub(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
Value * CreateAdd(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
void SetInsertPoint(BasicBlock *TheBB)
This specifies that created instructions should be appended to the end of the specified block.
Value * CreateICmp(CmpInst::Predicate P, Value *LHS, Value *RHS, const Twine &Name="")
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
const BasicBlock * getParent() const
SymbolTableList< Instruction >::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
void setDebugLoc(DebugLoc Loc)
Set the debug location information for this instruction.
void setSuccessor(unsigned Idx, BasicBlock *BB)
Update the specified successor to point at the provided block.
bool contains(const LoopT *L) const
Return true if the specified loop is contained within in this loop.
BlockT * getLoopLatch() const
If there is a single latch block for this loop, return it.
BlockT * getHeader() const
ArrayRef< BlockT * > getBlocks() const
Get a list of the basic blocks which make up this loop.
Store the result of a depth first search within basic blocks contained by a single loop.
RPOIterator beginRPO() const
Reverse iterate over the cached postorder blocks.
std::vector< BasicBlock * >::const_reverse_iterator RPOIterator
void perform(LoopInfo *LI)
Traverse the loop blocks and store the DFS result.
RPOIterator endRPO() const
void verify(const DominatorTreeBase< BlockT, false > &DomTree) const
LoopT * getLoopFor(const BlockT *BB) const
Return the inner most loop that BB lives in.
bool replacementPreservesLCSSAForm(Instruction *From, Value *To)
Returns true if replacing From with To everywhere is guaranteed to preserve LCSSA form.
Represents a single loop in the control flow graph.
void setLoopID(MDNode *LoopID) const
Set the llvm.loop loop id metadata for this loop.
void setLoopAlreadyUnrolled()
Add llvm.loop.unroll.disable to this loop's loop id metadata.
MDNode * getLoopID() const
Return the llvm.loop loop id metadata node for this loop if it is present.
MDNode * createBranchWeights(uint32_t TrueWeight, uint32_t FalseWeight)
Return metadata containing two branch weights.
void addIncoming(Value *V, BasicBlock *BB)
Add an incoming value to the end of the PHI list.
void setIncomingValueForBlock(const BasicBlock *BB, Value *V)
Set every incoming value(s) for block BB to V.
void setIncomingBlock(unsigned i, BasicBlock *BB)
void setIncomingValue(unsigned i, Value *V)
static PHINode * Create(Type *Ty, unsigned NumReservedValues, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Constructors - NumReservedValues is a hint for the number of incoming edges that this phi node will h...
Value * getIncomingValue(unsigned i) const
Return incoming value number x.
int getBasicBlockIndex(const BasicBlock *BB) const
Return the first index of the specified basic block in the value list for this PHI.
This class uses information about analyze scalars to rewrite expressions in canonical form.
bool isHighCostExpansion(ArrayRef< const SCEV * > Exprs, Loop *L, unsigned Budget, const TargetTransformInfo *TTI, const Instruction *At)
Return true for expressions that can't be evaluated at runtime within given Budget.
Value * expandCodeFor(const SCEV *SH, Type *Ty, Instruction *I)
Insert code to directly compute the specified SCEV expression into the program.
This class represents an analyzed expression in the program.
Type * getType() const
Return the LLVM type of this SCEV expression.
The main scalar evolution driver.
const SCEV * getConstant(ConstantInt *V)
bool loopHasNoAbnormalExits(const Loop *L)
Return true if the loop has no abnormal exits.
void forgetTopmostLoop(const Loop *L)
void forgetValue(Value *V)
This method should be called by the client when it has changed a value in a way that may effect its v...
const SCEV * getExitCount(const Loop *L, const BasicBlock *ExitingBlock, ExitCountKind Kind=Exact)
Return the number of times the backedge executes before the given exit would be taken; if not exactly...
const SCEV * getAddExpr(SmallVectorImpl< const SCEV * > &Ops, SCEV::NoWrapFlags Flags=SCEV::FlagAnyWrap, unsigned Depth=0)
Get a canonical add expression, or something simpler if possible.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
reference emplace_back(ArgTypes &&... Args)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
ValueT lookup(const KeyT &Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
bool erase(const KeyT &Val)
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
void setName(const Twine &Name)
Change the name of the value.
StringRef getName() const
Return a constant reference to the value's name.
self_iterator getIterator()
initializer< Ty > init(const Ty &Val)
This is an optimization pass for GlobalISel generic memory operations.
bool RecursivelyDeleteTriviallyDeadInstructions(Value *V, const TargetLibraryInfo *TLI=nullptr, MemorySSAUpdater *MSSAU=nullptr, std::function< void(Value *)> AboutToDeleteCallback=std::function< void(Value *)>())
If the specified value is a trivially dead instruction, delete it.
auto successors(const MachineBasicBlock *BB)
std::optional< MDNode * > makeFollowupLoopID(MDNode *OrigLoopID, ArrayRef< StringRef > FollowupAttrs, const char *InheritOptionsAttrsPrefix="", bool AlwaysNew=false)
Create a new loop identifier for a loop created from a loop transformation.
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
bool isInstructionTriviallyDead(Instruction *I, const TargetLibraryInfo *TLI=nullptr)
Return true if the result produced by the instruction is not used, and the instruction will return.
unsigned Log2_32(uint32_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
BasicBlock * CloneBasicBlock(const BasicBlock *BB, ValueToValueMapTy &VMap, const Twine &NameSuffix="", Function *F=nullptr, ClonedCodeInfo *CodeInfo=nullptr, DebugInfoFinder *DIFinder=nullptr)
Return a copy of the specified basic block, but without embedding the block into a particular functio...
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
@ RF_IgnoreMissingLocals
If this flag is set, the remapper ignores missing function-local entries (Argument,...
@ RF_NoModuleLevelChanges
If this flag is set, the remapper knows that only local values within a function (such as an instruct...
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
cl::opt< unsigned > SCEVCheapExpansionBudget
void RemapInstruction(Instruction *I, ValueToValueMapTy &VM, RemapFlags Flags=RF_None, ValueMapTypeRemapper *TypeMapper=nullptr, ValueMaterializer *Materializer=nullptr)
Convert the instruction operands from referencing the current values into those specified by VM.
void breakLoopBackedge(Loop *L, DominatorTree &DT, ScalarEvolution &SE, LoopInfo &LI, MemorySSA *MSSA)
Remove the backedge of the specified loop.
BasicBlock * SplitBlockPredecessors(BasicBlock *BB, ArrayRef< BasicBlock * > Preds, const char *Suffix, DominatorTree *DT, LoopInfo *LI=nullptr, MemorySSAUpdater *MSSAU=nullptr, bool PreserveLCSSA=false)
This method introduces at least one new basic block into the function and moves some of the predecess...
const char *const LLVMLoopUnrollFollowupAll
bool MergeBlockIntoPredecessor(BasicBlock *BB, DomTreeUpdater *DTU=nullptr, LoopInfo *LI=nullptr, MemorySSAUpdater *MSSAU=nullptr, MemoryDependenceResults *MemDep=nullptr, bool PredecessorWithTwoSuccessors=false, DominatorTree *DT=nullptr)
Attempts to merge a block into its predecessor, if possible.
Value * simplifyInstruction(Instruction *I, const SimplifyQuery &Q, OptimizationRemarkEmitter *ORE=nullptr)
See if we can compute a simplified version of this instruction.
bool formDedicatedExitBlocks(Loop *L, DominatorTree *DT, LoopInfo *LI, MemorySSAUpdater *MSSAU, bool PreserveLCSSA)
Ensure that all exit blocks of the loop are dedicated exits.
bool isGuaranteedNotToBeUndefOrPoison(const Value *V, AssumptionCache *AC=nullptr, const Instruction *CtxI=nullptr, const DominatorTree *DT=nullptr, unsigned Depth=0)
Return true if this function can prove that V does not have undef bits and is never poison.
const char *const LLVMLoopUnrollFollowupRemainder
bool extractBranchWeights(const MDNode *ProfileData, SmallVectorImpl< uint32_t > &Weights)
Extract branch weights from MD_prof metadata.
const Loop * addClonedBlockToLoopInfo(BasicBlock *OriginalBB, BasicBlock *ClonedBB, LoopInfo *LI, NewLoopsMap &NewLoops)
Adds ClonedBB to LoopInfo, creates a new loop for ClonedBB if necessary and adds a mapping from the o...
auto predecessors(const MachineBasicBlock *BB)
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
LoopUnrollResult UnrollLoop(Loop *L, UnrollLoopOptions ULO, LoopInfo *LI, ScalarEvolution *SE, DominatorTree *DT, AssumptionCache *AC, const llvm::TargetTransformInfo *TTI, OptimizationRemarkEmitter *ORE, bool PreserveLCSSA, Loop **RemainderLoop=nullptr)
Unroll the given loop by Count.
BasicBlock * SplitBlock(BasicBlock *Old, Instruction *SplitPt, DominatorTree *DT, LoopInfo *LI=nullptr, MemorySSAUpdater *MSSAU=nullptr, const Twine &BBName="", bool Before=false)
Split the specified block at the specified instruction.
BasicBlock * SplitEdge(BasicBlock *From, BasicBlock *To, DominatorTree *DT=nullptr, LoopInfo *LI=nullptr, MemorySSAUpdater *MSSAU=nullptr, const Twine &BBName="")
Split the edge connecting the specified blocks, and return the newly created basic block between From...
bool UnrollRuntimeLoopRemainder(Loop *L, unsigned Count, bool AllowExpensiveTripCount, bool UseEpilogRemainder, bool UnrollRemainder, bool ForgetAllSCEV, LoopInfo *LI, ScalarEvolution *SE, DominatorTree *DT, AssumptionCache *AC, const TargetTransformInfo *TTI, bool PreserveLCSSA, Loop **ResultLoop=nullptr)
Insert code in the prolog/epilog code when unrolling a loop with a run-time trip-count.