81#define DEBUG_TYPE "loop-flatten"
83STATISTIC(NumFlattened,
"Number of loops flattened");
87 cl::desc(
"Limit on the cost of instructions that can be repeated due to "
93 cl::desc(
"Assume that the product of the two iteration "
94 "trip counts will never overflow"));
98 cl::desc(
"Widen the loop induction variables, if possible, so "
99 "overflow checks won't reject flattening"));
103 cl::desc(
"Version loops if flattened loop could overflow"));
115 Loop *OuterLoop =
nullptr;
116 Loop *InnerLoop =
nullptr;
118 PHINode *InnerInductionPHI =
nullptr;
119 PHINode *OuterInductionPHI =
nullptr;
123 Value *InnerTripCount =
nullptr;
124 Value *OuterTripCount =
nullptr;
141 bool Widened =
false;
144 PHINode *NarrowInnerInductionPHI =
nullptr;
145 PHINode *NarrowOuterInductionPHI =
nullptr;
149 Value *NewTripCount =
nullptr;
151 FlattenInfo(
Loop *OL,
Loop *IL) : OuterLoop(OL), InnerLoop(IL){};
153 bool isNarrowInductionPhi(
PHINode *Phi) {
157 return NarrowInnerInductionPHI ==
Phi || NarrowOuterInductionPHI ==
Phi;
159 bool isInnerLoopIncrement(
User *U) {
160 return InnerIncrement ==
U;
162 bool isOuterLoopIncrement(
User *U) {
163 return OuterIncrement ==
U;
165 bool isInnerLoopTest(
User *U) {
170 for (
User *U : OuterInductionPHI->
users()) {
171 if (isOuterLoopIncrement(U))
174 auto IsValidOuterPHIUses = [&] (
User *
U) ->
bool {
175 LLVM_DEBUG(
dbgs() <<
"Found use of outer induction variable: ";
U->dump());
176 if (!ValidOuterPHIUses.
count(U)) {
177 LLVM_DEBUG(
dbgs() <<
"Did not match expected pattern, bailing\n");
184 if (
auto *V = dyn_cast<TruncInst>(U)) {
185 for (
auto *K :
V->users()) {
186 if (!IsValidOuterPHIUses(K))
192 if (!IsValidOuterPHIUses(U))
198 bool matchLinearIVUser(
User *U,
Value *InnerTripCount,
200 LLVM_DEBUG(
dbgs() <<
"Checking linear i*M+j expression for: ";
U->dump());
201 Value *MatchedMul =
nullptr;
202 Value *MatchedItCount =
nullptr;
232 return !isInstructionTriviallyDead(cast<Instruction>(U));
240 if (Widened && (IsAdd || IsGEP) &&
241 (isa<SExtInst>(MatchedItCount) || isa<ZExtInst>(MatchedItCount))) {
243 "Unexpected type mismatch in types after widening");
244 MatchedItCount = isa<SExtInst>(MatchedItCount)
245 ? dyn_cast<SExtInst>(MatchedItCount)->getOperand(0)
246 : dyn_cast<ZExtInst>(MatchedItCount)->getOperand(0);
250 InnerTripCount->
dump());
252 if ((IsAdd || IsAddTrunc || IsGEP) && MatchedItCount == InnerTripCount) {
254 ValidOuterPHIUses.
insert(MatchedMul);
259 LLVM_DEBUG(
dbgs() <<
"Did not match expected pattern, bailing\n");
264 Value *SExtInnerTripCount = InnerTripCount;
266 (isa<SExtInst>(InnerTripCount) || isa<ZExtInst>(InnerTripCount)))
267 SExtInnerTripCount = cast<Instruction>(InnerTripCount)->getOperand(0);
269 for (
User *U : InnerInductionPHI->
users()) {
271 if (isInnerLoopIncrement(U)) {
272 LLVM_DEBUG(
dbgs() <<
"Use is inner loop increment, continuing\n");
278 if (isa<TruncInst>(U)) {
281 U = *
U->user_begin();
288 if (isInnerLoopTest(U)) {
293 if (!matchLinearIVUser(U, SExtInnerTripCount, ValidOuterPHIUses)) {
308 IterationInstructions.
insert(Increment);
326 if (isa<SCEVCouldNotCompute>(BackedgeTakenCount)) {
327 LLVM_DEBUG(
dbgs() <<
"Backedge-taken count is not predictable\n");
334 const SCEV *SCEVTripCount =
336 BackedgeTakenCount->
getType(), L);
339 if (SCEVRHS == SCEVTripCount)
343 const SCEV *BackedgeTCExt =
nullptr;
345 const SCEV *SCEVTripCountExt;
351 if (SCEVRHS != BackedgeTCExt && SCEVRHS != SCEVTripCountExt) {
358 if (SCEVRHS == BackedgeTCExt || SCEVRHS == BackedgeTakenCount) {
362 IterationInstructions);
373 auto *TripCountInst = dyn_cast<Instruction>(
RHS);
374 if (!TripCountInst) {
378 if ((!isa<ZExtInst>(TripCountInst) && !isa<SExtInst>(TripCountInst)) ||
379 SE->
getSCEV(TripCountInst->getOperand(0)) != SCEVTripCount) {
380 LLVM_DEBUG(
dbgs() <<
"Could not find valid extended trip count\n");
392 LLVM_DEBUG(
dbgs() <<
"Finding components of loop: " << L->getName() <<
"\n");
394 if (!L->isLoopSimplifyForm()) {
401 if (!L->isCanonical(*SE)) {
409 if (L->getExitingBlock() != Latch) {
417 InductionPHI = L->getInductionVariable(*SE);
434 ICmpInst *Compare = L->getLatchCmpInst();
435 if (!Compare || !IsValidPredicate(Compare->getUnsignedPredicate()) ||
436 Compare->hasNUsesOrMore(2)) {
441 IterationInstructions.
insert(BackBranch);
443 IterationInstructions.
insert(Compare);
452 if ((Compare->getOperand(0) != Increment || !Increment->hasNUses(2)) &&
453 !Increment->hasNUses(1)) {
462 Value *
RHS = Compare->getOperand(1);
465 Increment, BackBranch, SE, IsWidened);
484 SafeOuterPHIs.
insert(FI.OuterInductionPHI);
488 for (
PHINode &InnerPHI : FI.InnerLoop->getHeader()->phis()) {
491 if (&InnerPHI == FI.InnerInductionPHI)
493 if (FI.isNarrowInductionPhi(&InnerPHI))
498 assert(InnerPHI.getNumIncomingValues() == 2);
499 Value *PreHeaderValue =
500 InnerPHI.getIncomingValueForBlock(FI.InnerLoop->getLoopPreheader());
502 InnerPHI.getIncomingValueForBlock(FI.InnerLoop->getLoopLatch());
507 PHINode *OuterPHI = dyn_cast<PHINode>(PreHeaderValue);
508 if (!OuterPHI || OuterPHI->
getParent() != FI.OuterLoop->getHeader()) {
517 PHINode *LCSSAPHI = dyn_cast<PHINode>(
528 dbgs() <<
"LCSSA PHI incoming value does not match latch value\n");
535 SafeOuterPHIs.
insert(OuterPHI);
536 FI.InnerPHIsToTransform.insert(&InnerPHI);
539 for (
PHINode &OuterPHI : FI.OuterLoop->getHeader()->phis()) {
540 if (FI.isNarrowInductionPhi(&OuterPHI))
542 if (!SafeOuterPHIs.
count(&OuterPHI)) {
543 LLVM_DEBUG(
dbgs() <<
"found unsafe PHI in outer loop: "; OuterPHI.dump());
562 for (
auto *
B : FI.OuterLoop->getBlocks()) {
563 if (FI.InnerLoop->contains(
B))
567 if (!isa<PHINode>(&
I) && !
I.isTerminator() &&
569 LLVM_DEBUG(
dbgs() <<
"Cannot flatten because instruction may have "
578 if (IterationInstructions.
count(&
I))
594 RepeatedInstrCost +=
Cost;
598 LLVM_DEBUG(
dbgs() <<
"Cost of instructions that will be repeated: "
599 << RepeatedInstrCost <<
"\n");
603 LLVM_DEBUG(
dbgs() <<
"checkOuterLoopInsts: not profitable, bailing.\n");
624 if (!FI.checkInnerInductionPhiUsers(ValidOuterPHIUses))
629 if (!FI.checkOuterInductionPhiUsers(ValidOuterPHIUses))
633 dbgs() <<
"Found " << FI.LinearIVUses.size()
634 <<
" value(s) that can be replaced:\n";
635 for (
Value *V : FI.LinearIVUses) {
646 Function *
F = FI.OuterLoop->getHeader()->getParent();
651 return OverflowResult::NeverOverflows;
656 FI.InnerTripCount, FI.OuterTripCount,
658 FI.OuterLoop->getLoopPreheader()->getTerminator()));
659 if (OR != OverflowResult::MayOverflow)
663 for (
Value *GEPUser :
GEP->users()) {
664 auto *GEPUserInst = cast<Instruction>(GEPUser);
665 if (!isa<LoadInst>(GEPUserInst) &&
666 !(isa<StoreInst>(GEPUserInst) &&
GEP == GEPUserInst->getOperand(1)))
674 if (
GEP->isInBounds() &&
675 GEPOperand->getType()->getIntegerBitWidth() >=
676 DL.getPointerTypeSizeInBits(
GEP->getType())) {
678 dbgs() <<
"use of linear IV would be UB if overflow occurred: ";
688 for (
Value *V : FI.LinearIVUses) {
689 if (
auto *
GEP = dyn_cast<GetElementPtrInst>(V))
690 if (
GEP->getNumIndices() == 1 && CheckGEP(
GEP,
GEP->getOperand(1)))
691 return OverflowResult::NeverOverflows;
692 for (
Value *U : V->users())
693 if (
auto *
GEP = dyn_cast<GetElementPtrInst>(U))
694 if (CheckGEP(
GEP, V))
695 return OverflowResult::NeverOverflows;
698 return OverflowResult::MayOverflow;
706 FI.InnerInductionPHI, FI.InnerTripCount,
707 FI.InnerIncrement, FI.InnerBranch, SE, FI.Widened))
710 FI.OuterInductionPHI, FI.OuterTripCount,
711 FI.OuterIncrement, FI.OuterBranch, SE, FI.Widened))
716 if (!FI.OuterLoop->isLoopInvariant(FI.InnerTripCount)) {
720 if (!FI.OuterLoop->isLoopInvariant(FI.OuterTripCount)) {
729 if (FI.InnerInductionPHI->getType() != FI.OuterInductionPHI->getType())
751 Function *
F = FI.OuterLoop->getHeader()->getParent();
752 LLVM_DEBUG(
dbgs() <<
"Checks all passed, doing the transformation\n");
756 FI.InnerLoop->getHeader());
758 Remark <<
"Flattened into outer loop";
762 if (!FI.NewTripCount) {
763 FI.NewTripCount = BinaryOperator::CreateMul(
764 FI.InnerTripCount, FI.OuterTripCount,
"flatten.tripcount",
765 FI.OuterLoop->getLoopPreheader()->getTerminator()->getIterator());
767 FI.NewTripCount->dump());
772 FI.InnerInductionPHI->removeIncomingValue(FI.InnerLoop->getLoopLatch());
777 PHI->removeIncomingValue(FI.InnerLoop->getLoopLatch());
781 cast<User>(FI.OuterBranch->getCondition())->setOperand(1, FI.NewTripCount);
784 BasicBlock *InnerExitBlock = FI.InnerLoop->getExitBlock();
785 BasicBlock *InnerExitingBlock = FI.InnerLoop->getExitingBlock();
789 Term->eraseFromParent();
792 DT->
deleteEdge(InnerExitingBlock, FI.InnerLoop->getHeader());
794 MSSAU->
removeEdge(InnerExitingBlock, FI.InnerLoop->getHeader());
798 IRBuilder<> Builder(FI.OuterInductionPHI->getParent()->getTerminator());
799 for (
Value *V : FI.LinearIVUses) {
800 Value *OuterValue = FI.OuterInductionPHI;
802 OuterValue = Builder.
CreateTrunc(FI.OuterInductionPHI, V->getType(),
805 if (
auto *
GEP = dyn_cast<GetElementPtrInst>(V)) {
807 auto *InnerGEP = cast<GetElementPtrInst>(
GEP->getOperand(0));
815 "flatten." + V->getName(),
816 GEP->isInBounds() && InnerGEP->isInBounds());
821 V->replaceAllUsesWith(OuterValue);
829 U->markLoopAsDeleted(*FI.InnerLoop, FI.InnerLoop->getName());
830 LI->
erase(FI.InnerLoop);
847 Module *M = FI.InnerLoop->getHeader()->getParent()->getParent();
848 auto &
DL = M->getDataLayout();
849 auto *InnerType = FI.InnerInductionPHI->getType();
850 auto *OuterType = FI.OuterInductionPHI->getType();
851 unsigned MaxLegalSize =
DL.getLargestLegalIntTypeSizeInBits();
852 auto *MaxLegalType =
DL.getLargestLegalIntType(M->getContext());
857 if (InnerType != OuterType ||
858 InnerType->getScalarSizeInBits() >= MaxLegalSize ||
859 MaxLegalType->getScalarSizeInBits() <
860 InnerType->getScalarSizeInBits() * 2) {
867 unsigned ElimExt = 0;
868 unsigned Widened = 0;
883 if (!CreateWideIV({FI.InnerInductionPHI, MaxLegalType,
false},
Deleted))
888 FI.InnerPHIsToTransform.insert(FI.InnerInductionPHI);
890 if (!CreateWideIV({FI.OuterInductionPHI, MaxLegalType,
false},
Deleted))
893 assert(Widened &&
"Widened IV expected");
897 FI.NarrowInnerInductionPHI = FI.InnerInductionPHI;
898 FI.NarrowOuterInductionPHI = FI.OuterInductionPHI;
910 dbgs() <<
"Loop flattening running on outer loop "
911 << FI.OuterLoop->getHeader()->getName() <<
" and inner loop "
912 << FI.InnerLoop->getHeader()->getName() <<
" in "
913 << FI.OuterLoop->getHeader()->getParent()->getName() <<
"\n");
932 if (FI.Widened && !CanFlatten)
944 if (OR == OverflowResult::AlwaysOverflowsHigh ||
945 OR == OverflowResult::AlwaysOverflowsLow) {
946 LLVM_DEBUG(
dbgs() <<
"Multiply would always overflow, so not profitable\n");
948 }
else if (OR == OverflowResult::MayOverflow) {
949 Module *M = FI.OuterLoop->getHeader()->getParent()->getParent();
952 LLVM_DEBUG(
dbgs() <<
"Multiply might overflow, not flattening\n");
954 }
else if (!
DL.isLegalInteger(
955 FI.OuterTripCount->getType()->getScalarSizeInBits())) {
960 dbgs() <<
"Can't check overflow efficiently, not flattening\n");
963 LLVM_DEBUG(
dbgs() <<
"Multiply might overflow, versioning loop\n");
968 BasicBlock *CheckBlock = FI.OuterLoop->getLoopPreheader();
977 "Expected LoopVersioning to generate a conditional branch");
979 "Expected branch condition to be false");
982 FI.OuterTripCount->getType());
989 LLVM_DEBUG(
dbgs() <<
"Multiply cannot overflow, modifying loop in-place\n");
999 bool Changed =
false;
1001 std::optional<MemorySSAUpdater> MSSAU;
1017 FlattenInfo FI(OuterLoop, InnerLoop);
1020 MSSAU ? &*MSSAU :
nullptr, LAIM.
getInfo(*OuterLoop));
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static bool CanWidenIV(FlattenInfo &FI, DominatorTree *DT, LoopInfo *LI, ScalarEvolution *SE, AssumptionCache *AC, const TargetTransformInfo *TTI)
static bool verifyTripCount(Value *RHS, Loop *L, SmallPtrSetImpl< Instruction * > &IterationInstructions, PHINode *&InductionPHI, Value *&TripCount, BinaryOperator *&Increment, BranchInst *&BackBranch, ScalarEvolution *SE, bool IsWidened)
static cl::opt< bool > WidenIV("loop-flatten-widen-iv", cl::Hidden, cl::init(true), cl::desc("Widen the loop induction variables, if possible, so " "overflow checks won't reject flattening"))
static bool setLoopComponents(Value *&TC, Value *&TripCount, BinaryOperator *&Increment, SmallPtrSetImpl< Instruction * > &IterationInstructions)
static bool DoFlattenLoopPair(FlattenInfo &FI, DominatorTree *DT, LoopInfo *LI, ScalarEvolution *SE, AssumptionCache *AC, const TargetTransformInfo *TTI, LPMUpdater *U, MemorySSAUpdater *MSSAU)
static bool FlattenLoopPair(FlattenInfo &FI, DominatorTree *DT, LoopInfo *LI, ScalarEvolution *SE, AssumptionCache *AC, const TargetTransformInfo *TTI, LPMUpdater *U, MemorySSAUpdater *MSSAU, const LoopAccessInfo &LAI)
static bool checkIVUsers(FlattenInfo &FI)
static bool CanFlattenLoopPair(FlattenInfo &FI, DominatorTree *DT, LoopInfo *LI, ScalarEvolution *SE, AssumptionCache *AC, const TargetTransformInfo *TTI)
static cl::opt< bool > VersionLoops("loop-flatten-version-loops", cl::Hidden, cl::init(true), cl::desc("Version loops if flattened loop could overflow"))
static bool findLoopComponents(Loop *L, SmallPtrSetImpl< Instruction * > &IterationInstructions, PHINode *&InductionPHI, Value *&TripCount, BinaryOperator *&Increment, BranchInst *&BackBranch, ScalarEvolution *SE, bool IsWidened)
static OverflowResult checkOverflow(FlattenInfo &FI, DominatorTree *DT, AssumptionCache *AC)
static bool checkPHIs(FlattenInfo &FI, const TargetTransformInfo *TTI)
static cl::opt< unsigned > RepeatedInstructionThreshold("loop-flatten-cost-threshold", cl::Hidden, cl::init(2), cl::desc("Limit on the cost of instructions that can be repeated due to " "loop flattening"))
static cl::opt< bool > AssumeNoOverflow("loop-flatten-assume-no-overflow", cl::Hidden, cl::init(false), cl::desc("Assume that the product of the two iteration " "trip counts will never overflow"))
static bool checkOuterLoopInsts(FlattenInfo &FI, SmallPtrSetImpl< Instruction * > &IterationInstructions, const TargetTransformInfo *TTI)
This file defines the interface for the loop nest analysis.
This header provides classes for managing a pipeline of passes over loops in LLVM IR.
Module.h This file contains the declarations for the Module class.
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)
Virtual Register Rewriter
A container for analyses that lazily runs them and caches their results.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
A cache of @llvm.assume calls within a function.
LLVM Basic Block Representation.
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)
bool isConditional() const
static BranchInst * Create(BasicBlock *IfTrue, InsertPosition InsertBefore=nullptr)
BasicBlock * getSuccessor(unsigned i) const
bool isUnconditional() const
Value * getCondition() const
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
@ ICMP_ULT
unsigned less than
This is the shared class of boolean and integer constants.
const APInt & getValue() const
Return the constant as an APInt value reference.
A parsed version of the target data layout string in and methods for querying it.
void deleteEdge(NodeT *From, NodeT *To)
Inform the dominator tree about a CFG edge deletion and update the tree.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
bool dominates(const BasicBlock *BB, const Use &U) const
Return true if the (end of the) basic block BB dominates the use U.
an instruction for type-safe pointer arithmetic to access elements of arrays and structs
This instruction compares its operands according to the predicate given to the constructor.
Value * CreateExtractValue(Value *Agg, ArrayRef< unsigned > Idxs, const Twine &Name="")
BasicBlock::iterator GetInsertPoint() const
Value * CreateGEP(Type *Ty, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &Name="", GEPNoWrapFlags NW=GEPNoWrapFlags::none())
Value * CreateTrunc(Value *V, Type *DestTy, const Twine &Name="", bool IsNUW=false, bool IsNSW=false)
void SetInsertPoint(BasicBlock *TheBB)
This specifies that created instructions should be appended to the end of the specified block.
CallInst * CreateCall(FunctionType *FTy, Value *Callee, ArrayRef< Value * > Args=std::nullopt, const Twine &Name="", MDNode *FPMathTag=nullptr)
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
BasicBlock * getSuccessor(unsigned Idx) const LLVM_READONLY
Return the specified successor. This instruction must be a terminator.
void setDebugLoc(DebugLoc Loc)
Set the debug location information for this instruction.
This class provides an interface for updating the loop pass manager based on mutations to the loop ne...
const LoopAccessInfo & getInfo(Loop &L)
Drive the analysis of memory accesses in the loop.
LoopT * getParentLoop() const
Return the parent loop if it exists or nullptr for top level loops.
PreservedAnalyses run(LoopNest &LN, LoopAnalysisManager &LAM, LoopStandardAnalysisResults &AR, LPMUpdater &U)
void erase(Loop *L)
Update LoopInfo after removing the last backedge from a loop.
This class represents a loop nest and can be used to query its properties.
ArrayRef< Loop * > getLoops() const
Get the loops in the nest.
This class emits a version of the loop where run-time checks ensure that may-alias pointers can't ove...
void versionLoop()
Performs the CFG manipulation part of versioning the loop including the DominatorTree and LoopInfo up...
Represents a single loop in the control flow graph.
An analysis that produces MemorySSA for a function.
void removeEdge(BasicBlock *From, BasicBlock *To)
Update the MemoryPhi in To following an edge deletion between From and To.
void verifyMemorySSA(VerificationLevel=VerificationLevel::Fast) const
Verify that MemorySSA is self consistent (IE definitions dominate all uses, uses appear in the right ...
A Module instance is used to store all the information related to an LLVM module.
Value * getIncomingValueForBlock(const BasicBlock *BB) const
Value * hasConstantValue() const
If the specified PHI node always merges together the same value, return the value,...
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
This class uses information about analyze scalars to rewrite expressions in canonical form.
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 * getBackedgeTakenCount(const Loop *L, ExitCountKind Kind=Exact)
If the specified loop has a predictable backedge-taken count, return it, otherwise return a SCEVCould...
const SCEV * getSCEV(Value *V)
Return a SCEV expression for the full generality of the specified expression.
const SCEV * getTripCountFromExitCount(const SCEV *ExitCount)
A version of getTripCountFromExitCount below which always picks an evaluation type which can not resu...
void forgetLoop(const Loop *L)
This method should be called by the client when it has changed a loop in a way that may effect Scalar...
const SCEV * getZeroExtendExpr(const SCEV *Op, Type *Ty, unsigned Depth=0)
void forgetBlockAndLoopDispositions(Value *V=nullptr)
Called when the client has changed the disposition of values in a loop or block.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
iterator_range< user_iterator > users()
LLVMContext & getContext() const
All values hold a context through their type.
void dump() const
Support for debugging, callable in GDB: V->dump()
const ParentTy * getParent() const
Function * getDeclaration(Module *M, ID id, ArrayRef< Type * > Tys=std::nullopt)
Create or insert an LLVM Function declaration for an intrinsic, and return it.
CastInst_match< OpTy, TruncInst > m_Trunc(const OpTy &Op)
Matches Trunc.
bool match(Val *V, const Pattern &P)
specificval_ty m_Specific(const Value *V)
Match if we have a specific specified value.
auto m_GEP(const OperandTypes &...Ops)
Matches GetElementPtrInst.
BinaryOp_match< LHS, RHS, Instruction::Add, true > m_c_Add(const LHS &L, const RHS &R)
Matches a Add with LHS and RHS in either order.
class_match< Value > m_Value()
Match an arbitrary value and ignore it.
is_zero m_Zero()
Match any null constant or a vector with all elements equal to 0.
BinaryOp_match< LHS, RHS, Instruction::Mul, true > m_c_Mul(const LHS &L, const RHS &R)
Matches a Mul with LHS and RHS in either order.
initializer< Ty > init(const Ty &Val)
NodeAddr< PhiNode * > Phi
This is an optimization pass for GlobalISel generic memory operations.
PHINode * createWideIV(const WideIVInfo &WI, LoopInfo *LI, ScalarEvolution *SE, SCEVExpander &Rewriter, DominatorTree *DT, SmallVectorImpl< WeakTrackingVH > &DeadInsts, unsigned &NumElimExt, unsigned &NumWidened, bool HasGuards, bool UsePostIncrementRanges)
Widen Induction Variables - Extend the width of an IV to cover its widest uses.
bool isGuaranteedToExecuteForEveryIteration(const Instruction *I, const Loop *L)
Return true if this function can prove that the instruction I is executed for every iteration of the ...
OverflowResult computeOverflowForUnsignedMul(const Value *LHS, const Value *RHS, const SimplifyQuery &SQ, bool IsNSW=false)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool isSafeToSpeculativelyExecute(const Instruction *I, const Instruction *CtxI=nullptr, AssumptionCache *AC=nullptr, const DominatorTree *DT=nullptr, const TargetLibraryInfo *TLI=nullptr, bool UseVariableInfo=true)
Return true if the instruction does not have any effects besides calculating the result and does not ...
bool VerifyMemorySSA
Enables verification of MemorySSA.
auto count_if(R &&Range, UnaryPredicate P)
Wrapper function around std::count_if to count the number of times an element satisfying a given pred...
PreservedAnalyses getLoopPassPreservedAnalyses()
Returns the minimum set of Analyses that all loop passes must preserve.
bool RecursivelyDeleteDeadPHINode(PHINode *PN, const TargetLibraryInfo *TLI=nullptr, MemorySSAUpdater *MSSAU=nullptr)
If the specified value is an effectively dead PHI node, due to being a def-use chain of single-use no...
The adaptor from a function pass to a loop pass computes these analyses and makes them available to t...
TargetTransformInfo & TTI
Collect information about induction variables that are used by sign/zero extend operations.