79#define DEBUG_TYPE "loop-unroll"
82STATISTIC(NumCompletelyUnrolled,
"Number of loops completely unrolled");
83STATISTIC(NumUnrolled,
"Number of loops unrolled (completely or otherwise)");
84STATISTIC(NumUnrolledNotLatch,
"Number of loops unrolled without a conditional "
85 "latch (completely or otherwise)");
89 cl::desc(
"Allow runtime unrolled loops to be unrolled "
90 "with epilog instead of prolog."));
94 cl::desc(
"Verify domtree after unrolling"),
95#ifdef EXPENSIVE_CHECKS
104 cl::desc(
"Verify loopinfo after unrolling"),
105#ifdef EXPENSIVE_CHECKS
123 const std::vector<BasicBlock *> &
Blocks,
129 for (
Use &U :
I.operands()) {
130 if (
const auto *Def = dyn_cast<Instruction>(U)) {
152 assert(OldLoop &&
"Should (at least) be in the loop being unrolled!");
154 Loop *&NewLoop = NewLoops[OldLoop];
158 "Header should be first in RPO");
202 BasicBlock *PreHeader = L->getLoopPreheader();
204 assert(PreHeader && Header);
205 for (
const PHINode &PN : Header->phis()) {
206 if (isa<ConstantInt>(PN.getIncomingValueForBlock(PreHeader)))
220 if (SE && SimplifyIVs) {
226 while (!DeadInsts.
empty()) {
228 if (
Instruction *Inst = dyn_cast_or_null<Instruction>(V))
235 const DataLayout &
DL = L->getHeader()->getModule()->getDataLayout();
241 Inst.replaceAllUsesWith(V);
274 bool PreserveLCSSA,
Loop **RemainderLoop) {
275 assert(DT &&
"DomTree is required");
277 if (!L->getLoopPreheader()) {
278 LLVM_DEBUG(
dbgs() <<
" Can't unroll; loop preheader-insertion failed.\n");
282 if (!L->getLoopLatch()) {
283 LLVM_DEBUG(
dbgs() <<
" Can't unroll; loop exit-block-insertion failed.\n");
288 if (!L->isSafeToClone()) {
289 LLVM_DEBUG(
dbgs() <<
" Can't unroll; Loop body cannot be cloned.\n");
293 if (L->getHeader()->hasAddressTaken()) {
296 dbgs() <<
" Won't unroll loop: address of header block is taken.\n");
304 BasicBlock *Preheader = L->getLoopPreheader();
308 L->getExitBlocks(ExitBlocks);
309 std::vector<BasicBlock *> OriginalLoopBlocks = L->getBlocks();
313 unsigned EstimatedLoopInvocationWeight = 0;
314 std::optional<unsigned> OriginalTripCount =
319 if (MaxTripCount && ULO.
Count > MaxTripCount)
320 ULO.
Count = MaxTripCount;
324 unsigned TripMultiple;
325 unsigned BreakoutTrip;
332 L->getExitingBlocks(ExitingBlocks);
333 for (
auto *ExitingBlock : ExitingBlocks) {
336 auto *BI = dyn_cast<BranchInst>(ExitingBlock->getTerminator());
343 if (
Info.TripCount != 0) {
345 Info.TripMultiple = 0;
347 Info.BreakoutTrip =
Info.TripMultiple =
350 Info.ExitOnTrue = !L->contains(BI->getSuccessor(0));
351 Info.ExitingBlocks.push_back(ExitingBlock);
352 LLVM_DEBUG(
dbgs() <<
" Exiting block %" << ExitingBlock->getName()
353 <<
": TripCount=" <<
Info.TripCount
354 <<
", TripMultiple=" <<
Info.TripMultiple
355 <<
", BreakoutTrip=" <<
Info.BreakoutTrip <<
"\n");
361 const bool CompletelyUnroll = ULO.
Count == MaxTripCount;
363 const bool PreserveOnlyFirst = CompletelyUnroll && MaxOrZero;
367 if (CompletelyUnroll)
376 bool NeedToFixLCSSA =
377 PreserveLCSSA && CompletelyUnroll &&
391 bool LatchIsExiting = L->isLoopExiting(LatchBlock);
392 if (!LatchBI || (LatchBI->isConditional() && !LatchIsExiting)) {
394 dbgs() <<
"Can't unroll; a conditional latch must exit the loop");
395 return LoopUnrollResult::Unmodified;
403 bool HasConvergent =
false;
404 for (
auto &BB : L->blocks())
406 if (
auto *CB = dyn_cast<CallBase>(&
I))
407 HasConvergent |= CB->isConvergent();
409 "Can't runtime unroll if loop contains a convergent operation.");
412 bool EpilogProfitability =
420 PreserveLCSSA, RemainderLoop)) {
425 "generated when assuming runtime trip count\n");
426 return LoopUnrollResult::Unmodified;
432 if (CompletelyUnroll) {
433 LLVM_DEBUG(
dbgs() <<
"COMPLETELY UNROLLING loop %" << Header->getName()
434 <<
" with trip count " << ULO.
Count <<
"!\n");
439 <<
"completely unrolled loop with "
440 << NV(
"UnrollCount", ULO.
Count) <<
" iterations";
443 LLVM_DEBUG(
dbgs() <<
"UNROLLING loop %" << Header->getName() <<
" by "
453 Diag <<
"unrolled loop by a factor of " << NV(
"UnrollCount", ULO.
Count);
455 Diag <<
" with run-time trip count";
478 ++NumUnrolledNotLatch;
483 std::vector<PHINode*> OrigPHINode;
485 OrigPHINode.push_back(cast<PHINode>(
I));
488 std::vector<BasicBlock *> Headers;
489 std::vector<BasicBlock *> Latches;
490 Headers.push_back(Header);
491 Latches.push_back(LatchBlock);
503 std::vector<BasicBlock*> UnrolledLoopBlocks = L->getBlocks();
510 for (
Loop *SubLoop : *L)
511 LoopsToSimplify.
insert(SubLoop);
515 if (Header->getParent()->shouldEmitDebugInfoForProfiling() &&
519 if (!
I.isDebugOrPseudoInst())
521 auto NewDIL = DIL->cloneByMultiplyingDuplicationFactor(ULO.
Count);
523 I.setDebugLoc(*NewDIL);
526 <<
"Failed to create new discriminator: "
527 << DIL->getFilename() <<
" Line: " << DIL->getLine());
538 auto BlockInsertPt = std::next(LatchBlock->
getIterator());
539 for (
unsigned It = 1; It != ULO.
Count; ++It) {
547 Header->getParent()->insert(BlockInsertPt, New);
550 "Header should not be in a sub-loop");
554 LoopsToSimplify.
insert(NewLoops[OldLoop]);
559 for (
PHINode *OrigPHI : OrigPHINode) {
560 PHINode *NewPHI = cast<PHINode>(VMap[OrigPHI]);
562 if (
Instruction *InValI = dyn_cast<Instruction>(InVal))
563 if (It > 1 && L->contains(InValI))
564 InVal = LastValueMap[InValI];
565 VMap[OrigPHI] = InVal;
570 LastValueMap[*BB] = New;
573 LastValueMap[
VI->first] =
VI->second;
577 if (L->contains(Succ))
580 Value *Incoming =
PHI.getIncomingValueForBlock(*BB);
582 if (It != LastValueMap.
end())
584 PHI.addIncoming(Incoming, New);
591 Headers.push_back(New);
592 if (*BB == LatchBlock)
593 Latches.push_back(New);
597 auto ExitInfoIt = ExitInfos.
find(*BB);
598 if (ExitInfoIt != ExitInfos.
end())
599 ExitInfoIt->second.ExitingBlocks.push_back(New);
602 UnrolledLoopBlocks.push_back(New);
611 auto BBDomNode = DT->
getNode(*BB);
612 auto BBIDom = BBDomNode->
getIDom();
613 BasicBlock *OriginalBBIDom = BBIDom->getBlock();
615 New, cast<BasicBlock>(LastValueMap[cast<Value>(OriginalBBIDom)]));
623 if (
auto *II = dyn_cast<AssumeInst>(&
I))
630 std::string ext = (
Twine(
"It") +
Twine(It)).str();
632 Header->getContext(), ext);
637 for (
PHINode *PN : OrigPHINode) {
638 if (CompletelyUnroll) {
639 PN->replaceAllUsesWith(PN->getIncomingValueForBlock(Preheader));
640 PN->eraseFromParent();
641 }
else if (ULO.
Count > 1) {
642 Value *InVal = PN->removeIncomingValue(LatchBlock,
false);
645 if (
Instruction *InValI = dyn_cast<Instruction>(InVal)) {
646 if (L->contains(InValI))
647 InVal = LastValueMap[InVal];
649 assert(Latches.back() == LastValueMap[LatchBlock] &&
"bad last latch");
650 PN->addIncoming(InVal, Latches.back());
656 for (
unsigned i = 0, e = Latches.size(); i != e; ++i) {
657 unsigned j = (i + 1) % e;
658 Latches[i]->getTerminator()->replaceSuccessorWith(Headers[i], Headers[j]);
666 for (
auto *BB : OriginalLoopBlocks) {
667 auto *BBDomNode = DT->
getNode(BB);
669 for (
auto *ChildDomNode : BBDomNode->children()) {
670 auto *ChildBB = ChildDomNode->getBlock();
671 if (!L->contains(ChildBB))
679 for (
auto *ChildBB : ChildrenToUpdate)
685 DT->
verify(DominatorTree::VerificationLevel::Fast));
688 auto SetDest = [&](
BasicBlock *Src,
bool WillExit,
bool ExitOnTrue) {
689 auto *Term = cast<BranchInst>(Src->getTerminator());
690 const unsigned Idx = ExitOnTrue ^ WillExit;
699 Term->eraseFromParent();
701 DTUpdates.
emplace_back(DominatorTree::Delete, Src, DeadSucc);
704 auto WillExit = [&](
const ExitInfo &
Info,
unsigned i,
unsigned j,
705 bool IsLatch) -> std::optional<bool> {
706 if (CompletelyUnroll) {
707 if (PreserveOnlyFirst) {
715 if (
Info.TripCount && j !=
Info.TripCount)
723 if (IsLatch && j != 0)
728 if (j !=
Info.BreakoutTrip &&
729 (
Info.TripMultiple == 0 || j %
Info.TripMultiple != 0)) {
739 for (
auto &Pair : ExitInfos) {
740 ExitInfo &
Info = Pair.second;
741 for (
unsigned i = 0, e =
Info.ExitingBlocks.size(); i != e; ++i) {
743 unsigned j = (i + 1) % e;
744 bool IsLatch = Pair.first == LatchBlock;
745 std::optional<bool> KnownWillExit = WillExit(
Info, i, j, IsLatch);
746 if (!KnownWillExit) {
747 if (!
Info.FirstExitingBlock)
748 Info.FirstExitingBlock =
Info.ExitingBlocks[i];
757 if (*KnownWillExit && !IsLatch) {
758 if (!
Info.FirstExitingBlock)
759 Info.FirstExitingBlock =
Info.ExitingBlocks[i];
763 SetDest(
Info.ExitingBlocks[i], *KnownWillExit,
Info.ExitOnTrue);
769 if (ExitingBlocks.
size() == 1 && ExitInfos.
size() == 1) {
777 auto &[OriginalExit,
Info] = *ExitInfos.
begin();
778 if (!
Info.FirstExitingBlock)
779 Info.FirstExitingBlock =
Info.ExitingBlocks.back();
781 if (L->contains(
C->getBlock()))
790 if (!LatchIsExiting && CompletelyUnroll) {
800 BranchInst *Term = dyn_cast<BranchInst>(Latch->getTerminator());
802 (CompletelyUnroll && !LatchIsExiting && Latch == Latches.back())) &&
803 "Need a branch as terminator, except when fully unrolling with "
804 "unconditional latch");
805 if (Term && Term->isUnconditional()) {
811 DTUToUse ?
nullptr : DT)) {
813 std::replace(Latches.begin(), Latches.end(), Dest, Fold);
824 DT->
verify(DominatorTree::VerificationLevel::Fast));
831 NumCompletelyUnrolled += CompletelyUnroll;
834 Loop *OuterL = L->getParentLoop();
836 if (CompletelyUnroll) {
840 }
else if (OriginalTripCount) {
844 EstimatedLoopInvocationWeight);
859 if (PreserveLCSSA && OuterL && CompletelyUnroll && !NeedToFixLCSSA)
869 if (NeedToFixLCSSA) {
874 Loop *FixLCSSALoop = OuterL;
875 if (!FixLCSSALoop->
contains(LatchLoop))
880 }
else if (PreserveLCSSA) {
882 "Loops should be in LCSSA form after loop-unroll.");
887 simplifyLoop(OuterL, DT, LI, SE, AC,
nullptr, PreserveLCSSA);
890 for (
Loop *SubLoop : LoopsToSimplify)
891 simplifyLoop(SubLoop, DT, LI, SE, AC,
nullptr, PreserveLCSSA);
894 return CompletelyUnroll ? LoopUnrollResult::FullyUnrolled
895 : LoopUnrollResult::PartiallyUnrolled;
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Analysis containing CSE Info
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
This file defines the DenseMap class.
DenseMap< Block *, BlockRelaxAux > Blocks
This file defines a set of templates that efficiently compute a dominator tree over a generic graph.
This file provides various utilities for inspecting and working with the control flow graph in LLVM I...
static bool needToInsertPhisForLCSSA(Loop *L, const std::vector< BasicBlock * > &Blocks, LoopInfo *LI)
Check if unrolling created a situation where we need to insert phi nodes to preserve LCSSA form.
static bool isEpilogProfitable(Loop *L)
The function chooses which type of unroll (epilog or prolog) is more profitabale.
static cl::opt< bool > UnrollRuntimeEpilog("unroll-runtime-epilog", cl::init(false), cl::Hidden, cl::desc("Allow runtime unrolled loops to be unrolled " "with epilog instead of prolog."))
static cl::opt< bool > UnrollVerifyLoopInfo("unroll-verify-loopinfo", cl::Hidden, cl::desc("Verify loopinfo after unrolling"), cl::init(false))
static cl::opt< bool > UnrollVerifyDomtree("unroll-verify-domtree", cl::Hidden, cl::desc("Verify domtree after unrolling"), cl::init(false))
Module.h This file contains the declarations for the Module class.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file implements a set that has insertion order iteration characteristics.
This file defines the SmallVector class.
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
This defines the Use class.
A cache of @llvm.assume calls within a function.
void registerAssumption(AssumeInst *CI)
Add an @llvm.assume intrinsic to this function's cache.
LLVM Basic Block Representation.
iterator begin()
Instruction iterator methods.
const BasicBlock * getUniquePredecessor() const
Return the predecessor of this block if it has a unique predecessor block.
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...
void removePredecessor(BasicBlock *Pred, bool KeepOneInputPHIs=false)
Update PHI nodes in this BasicBlock before removal of predecessor Pred.
Conditional or Unconditional Branch instruction.
static BranchInst * Create(BasicBlock *IfTrue, Instruction *InsertBefore=nullptr)
A parsed version of the target data layout string in and methods for querying it.
ValueT lookup(const_arg_type_t< KeyT > Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
iterator find(const_arg_type_t< KeyT > Val)
std::pair< iterator, bool > try_emplace(KeyT &&Key, Ts &&... Args)
iterator_range< iterator > children()
DomTreeNodeBase * getIDom() const
void applyUpdates(ArrayRef< DominatorTree::UpdateType > Updates)
Submit updates to all available trees.
DominatorTree & getDomTree()
Flush DomTree updates and return DomTree.
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...
SymbolTableList< Instruction >::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
bool contains(const LoopT *L) const
Return true if the specified loop is contained within in this loop.
BlockT * getHeader() const
void addBasicBlockToLoop(BlockT *NewBB, LoopInfoBase< BlockT, LoopT > &LI)
This method is used by other analyses to update loop information.
void addChildLoop(LoopT *NewChild)
Add the specified loop to be a child of this loop.
LoopT * getParentLoop() const
Return the parent loop if it exists or nullptr for top level loops.
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
void addTopLevelLoop(LoopT *New)
This adds the specified loop to the collection of top-level loops.
LoopT * AllocateLoop(ArgsTy &&...Args)
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.
void erase(Loop *L)
Update LoopInfo after removing the last backedge from a loop.
Represents a single loop in the control flow graph.
bool isLCSSAForm(const DominatorTree &DT, bool IgnoreTokens=true) const
Return true if the Loop is in LCSSA form.
const MDOperand & getOperand(unsigned I) const
unsigned getNumOperands() const
Return number of MDNode operands.
StringRef getString() const
Value * getIncomingValueForBlock(const BasicBlock *BB) const
The main scalar evolution driver.
unsigned getSmallConstantTripMultiple(const Loop *L, const SCEV *ExitCount)
Returns the largest constant divisor of the trip count as a normal unsigned value,...
unsigned getSmallConstantMaxTripCount(const Loop *L)
Returns the upper bound of the loop trip count as a normal unsigned value.
bool isBackedgeTakenCountMaxOrZero(const Loop *L)
Return true if the backedge taken count is either the value returned by getConstantMaxBackedgeTakenCo...
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...
void forgetBlockAndLoopDispositions(Value *V=nullptr)
Called when the client has changed the disposition of values in a loop or block.
unsigned getSmallConstantTripCount(const Loop *L)
Returns the exact trip count of the loop if we can compute it, and the result is a small constant.
bool insert(const value_type &X)
Insert a new element into the SetVector.
A SetVector that performs no allocations if smaller than a certain size.
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.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
A Use represents the edge between a Value definition and its users.
iterator find(const KeyT &Val)
LLVM Value Representation.
self_iterator getIterator()
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
@ C
The default llvm calling convention, compatible with C.
initializer< Ty > init(const Ty &Val)
This is an optimization pass for GlobalISel generic memory operations.
bool simplifyLoop(Loop *L, DominatorTree *DT, LoopInfo *LI, ScalarEvolution *SE, AssumptionCache *AC, MemorySSAUpdater *MSSAU, bool PreserveLCSSA)
Simplify each loop in a loop nest recursively.
std::optional< unsigned > getLoopEstimatedTripCount(Loop *L, unsigned *EstimatedLoopInvocationWeight=nullptr)
Returns a loop's estimated trip count based on branch weight metadata.
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)
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...
Value * simplifyInstruction(Instruction *I, const SimplifyQuery &Q)
See if we can compute a simplified version of this instruction.
cl::opt< bool > EnableFSDiscriminator
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
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.
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...
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool simplifyLoopIVs(Loop *L, ScalarEvolution *SE, DominatorTree *DT, LoopInfo *LI, const TargetTransformInfo *TTI, SmallVectorImpl< WeakTrackingVH > &Dead)
SimplifyLoopIVs - Simplify users of induction variables within this loop.
SmallVector< ValueTypeFromRangeType< R >, Size > to_vector(R &&Range)
Given a range of type R, iterate the entire range and return a SmallVector with elements of the vecto...
LoopUnrollResult
Represents the result of a UnrollLoop invocation.
@ Unmodified
The loop was not modified.
unsigned changeToUnreachable(Instruction *I, bool PreserveLCSSA=false, DomTreeUpdater *DTU=nullptr, MemorySSAUpdater *MSSAU=nullptr)
Insert an unreachable instruction before the specified instruction, making it and the rest of the cod...
bool formLCSSARecursively(Loop &L, const DominatorTree &DT, const LoopInfo *LI)
Put a loop nest into LCSSA form.
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.
void erase_value(Container &C, ValueType V)
Wrapper function to remove a value from a container:
bool setLoopEstimatedTripCount(Loop *L, unsigned EstimatedTripCount, unsigned EstimatedLoopInvocationWeight)
Set a loop's branch weight metadata to reflect that loop has EstimatedTripCount iterations and Estima...
void cloneAndAdaptNoAliasScopes(ArrayRef< MDNode * > NoAliasDeclScopes, ArrayRef< BasicBlock * > NewBlocks, LLVMContext &Context, StringRef Ext)
Clone the specified noalias decl scopes.
void remapInstructionsInBlocks(ArrayRef< BasicBlock * > Blocks, ValueToValueMapTy &VMap)
Remaps instructions in Blocks using the mapping in VMap.
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...
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.
void identifyNoAliasScopesToClone(ArrayRef< BasicBlock * > BBs, SmallVectorImpl< MDNode * > &NoAliasDeclScopes)
Find the 'llvm.experimental.noalias.scope.decl' intrinsics in the specified basic blocks and extract ...
void simplifyLoopAfterUnroll(Loop *L, bool SimplifyIVs, LoopInfo *LI, ScalarEvolution *SE, DominatorTree *DT, AssumptionCache *AC, const TargetTransformInfo *TTI)
Perform some cleanup and simplifications on loops after unrolling.
MDNode * GetUnrollMetadata(MDNode *LoopID, StringRef Name)
Given an llvm.loop loop id metadata node, returns the loop hint metadata node with the given name (fo...
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.
bool AllowExpensiveTripCount