34 using namespace llvm::PatternMatch;
36 #define DEBUG_TYPE "loop-utils"
41 if (!Set.
count(dyn_cast<Instruction>(*
Use)))
55 case RK_IntegerMinMax:
62 return (Kind != RK_NoRecurrence) && !isIntegerRecurrenceKind(Kind);
85 const APInt *M =
nullptr;
92 int32_t
Bits = (*M + 1).exactLogBase2();
109 bool FoundOneOperand =
false;
115 while (!Worklist.
empty()) {
122 if (!J || J == Start)
126 if (Visited.
count(J)) {
135 bool IsSExtInst = isa<SExtInst>(J);
136 if (!Cast || !Cast->
hasOneUse() || !(isa<ZExtInst>(J) || IsSExtInst))
142 if (SrcSize > DstSize)
146 if (FoundOneOperand) {
147 if (IsSigned != IsSExtInst)
150 FoundOneOperand =
true;
151 IsSigned = IsSExtInst;
157 if (SrcSize == DstSize)
165 Loop *TheLoop,
bool HasFunNoNaNAttr,
184 bool FoundReduxOp =
false;
190 bool FoundStartPHI =
false;
195 unsigned NumCmpSelectPatternInst = 0;
202 bool IsSigned =
false;
213 if (!isFloatingPointRecurrenceKind(Kind))
216 if (!isIntegerRecurrenceKind(Kind))
218 if (isArithmeticRecurrenceKind(Kind))
219 Start = lookThroughAnd(Phi, RecurrenceType, VisitedInsts, CastInsts);
223 VisitedInsts.
insert(Start);
239 while (!Worklist.
empty()) {
249 bool IsAPhi = isa<PHINode>(Cur);
257 if (!Cur->
isCommutative() && !IsAPhi && !isa<SelectInst>(Cur) &&
258 !isa<ICmpInst>(Cur) && !isa<FCmpInst>(Cur) &&
266 ReduxDesc = isRecurrenceInstr(Cur, Kind, ReduxDesc, HasFunNoNaNAttr);
272 if (!IsAPhi && Kind != RK_IntegerMinMax && Kind != RK_FloatMinMax &&
273 hasMultipleUsesOf(Cur, VisitedInsts))
277 if (IsAPhi && Cur != Phi && !areAllUsesIn(Cur, VisitedInsts))
280 if (Kind == RK_IntegerMinMax &&
281 (isa<ICmpInst>(Cur) || isa<SelectInst>(Cur)))
282 ++NumCmpSelectPatternInst;
283 if (Kind == RK_FloatMinMax && (isa<FCmpInst>(Cur) || isa<SelectInst>(Cur)))
284 ++NumCmpSelectPatternInst;
287 FoundReduxOp |= !IsAPhi && Cur != Start;
304 if (ExitInstruction !=
nullptr || Cur == Phi)
313 ExitInstruction = Cur;
320 InstDesc IgnoredVal(
false,
nullptr);
321 if (VisitedInsts.
insert(UI).second) {
322 if (isa<PHINode>(UI))
326 }
else if (!isa<PHINode>(UI) &&
327 ((!isa<FCmpInst>(UI) && !isa<ICmpInst>(UI) &&
328 !isa<SelectInst>(UI)) ||
329 !isMinMaxSelectCmpPattern(UI, IgnoredVal).isRecurrence()))
334 FoundStartPHI =
true;
342 if ((Kind == RK_IntegerMinMax || Kind == RK_FloatMinMax) &&
343 NumCmpSelectPatternInst != 2)
346 if (!FoundStartPHI || !FoundReduxOp || !ExitInstruction)
353 if (!getSourceExtensionKind(Start, ExitInstruction, RecurrenceType,
354 IsSigned, VisitedInsts, CastInsts))
377 assert((isa<ICmpInst>(I) || isa<FCmpInst>(I) || isa<SelectInst>(I)) &&
378 "Expect a select instruction");
384 if ((Cmp = dyn_cast<ICmpInst>(I)) || (Cmp = dyn_cast<FCmpInst>(I))) {
391 if (!(Select = dyn_cast<SelectInst>(I)))
393 if (!(Cmp = dyn_cast<ICmpInst>(I->
getOperand(0))) &&
404 return InstDesc(Select, MRK_UIntMin);
406 return InstDesc(Select, MRK_UIntMax);
408 return InstDesc(Select, MRK_SIntMax);
410 return InstDesc(Select, MRK_SIntMin);
412 return InstDesc(Select, MRK_FloatMin);
414 return InstDesc(Select, MRK_FloatMax);
416 return InstDesc(Select, MRK_FloatMin);
418 return InstDesc(Select, MRK_FloatMax);
425 InstDesc &Prev,
bool HasFunNoNaNAttr) {
434 case Instruction::PHI:
436 case Instruction::Sub:
438 return InstDesc(Kind == RK_IntegerAdd, I);
439 case Instruction::Mul:
440 return InstDesc(Kind == RK_IntegerMult, I);
442 return InstDesc(Kind == RK_IntegerAnd, I);
444 return InstDesc(Kind == RK_IntegerOr, I);
446 return InstDesc(Kind == RK_IntegerXor, I);
447 case Instruction::FMul:
448 return InstDesc(Kind == RK_FloatMult, I, UAI);
449 case Instruction::FSub:
450 case Instruction::FAdd:
451 return InstDesc(Kind == RK_FloatAdd, I, UAI);
452 case Instruction::FCmp:
453 case Instruction::ICmp:
455 if (Kind != RK_IntegerMinMax &&
456 (!HasFunNoNaNAttr || Kind != RK_FloatMinMax))
458 return isMinMaxSelectCmpPattern(I, Prev);
464 unsigned NumUses = 0;
467 if (Insts.
count(dyn_cast<Instruction>(*
Use)))
480 bool HasFunNoNaNAttr =
483 if (AddReductionVar(Phi, RK_IntegerAdd, TheLoop, HasFunNoNaNAttr, RedDes)) {
484 DEBUG(
dbgs() <<
"Found an ADD reduction PHI." << *Phi <<
"\n");
487 if (AddReductionVar(Phi, RK_IntegerMult, TheLoop, HasFunNoNaNAttr, RedDes)) {
488 DEBUG(
dbgs() <<
"Found a MUL reduction PHI." << *Phi <<
"\n");
491 if (AddReductionVar(Phi, RK_IntegerOr, TheLoop, HasFunNoNaNAttr, RedDes)) {
492 DEBUG(
dbgs() <<
"Found an OR reduction PHI." << *Phi <<
"\n");
495 if (AddReductionVar(Phi, RK_IntegerAnd, TheLoop, HasFunNoNaNAttr, RedDes)) {
496 DEBUG(
dbgs() <<
"Found an AND reduction PHI." << *Phi <<
"\n");
499 if (AddReductionVar(Phi, RK_IntegerXor, TheLoop, HasFunNoNaNAttr, RedDes)) {
500 DEBUG(
dbgs() <<
"Found a XOR reduction PHI." << *Phi <<
"\n");
503 if (AddReductionVar(Phi, RK_IntegerMinMax, TheLoop, HasFunNoNaNAttr,
505 DEBUG(
dbgs() <<
"Found a MINMAX reduction PHI." << *Phi <<
"\n");
508 if (AddReductionVar(Phi, RK_FloatMult, TheLoop, HasFunNoNaNAttr, RedDes)) {
509 DEBUG(
dbgs() <<
"Found an FMult reduction PHI." << *Phi <<
"\n");
512 if (AddReductionVar(Phi, RK_FloatAdd, TheLoop, HasFunNoNaNAttr, RedDes)) {
513 DEBUG(
dbgs() <<
"Found an FAdd reduction PHI." << *Phi <<
"\n");
516 if (AddReductionVar(Phi, RK_FloatMinMax, TheLoop, HasFunNoNaNAttr, RedDes)) {
517 DEBUG(
dbgs() <<
"Found an float MINMAX reduction PHI." << *Phi <<
"\n");
536 if (!Preheader || !Latch)
547 if (!Previous || !TheLoop->
contains(Previous) || isa<PHINode>(Previous))
554 if (
auto *
I = dyn_cast<Instruction>(U))
594 return Instruction::Mul;
602 return Instruction::FMul;
604 return Instruction::FAdd;
605 case RK_IntegerMinMax:
606 return Instruction::ICmp;
608 return Instruction::FCmp;
649 if (RK == MRK_FloatMin || RK == MRK_FloatMax)
650 Cmp = Builder.
CreateFCmp(P, Left, Right,
"rdx.minmax.cmp");
652 Cmp = Builder.
CreateICmp(P, Left, Right,
"rdx.minmax.cmp");
660 : StartValue(Start), IK(K), Step(Step), InductionBinOp(BOp) {
661 assert(IK != IK_NoInduction &&
"Not an induction");
665 assert(StartValue &&
"StartValue is null");
666 assert((IK != IK_PtrInduction || StartValue->getType()->isPointerTy()) &&
667 "StartValue is not a pointer for pointer induction");
668 assert((IK != IK_IntInduction || StartValue->getType()->isIntegerTy()) &&
669 "StartValue is not an integer for integer induction");
672 assert((!getConstIntStepValue() || !getConstIntStepValue()->
isZero()) &&
673 "Step value is zero");
675 assert((IK != IK_PtrInduction || getConstIntStepValue()) &&
676 "Step value should be constant for pointer induction");
678 "StepValue is not an integer");
681 "StepValue is not FP for FpInduction");
682 assert((IK != IK_FpInduction || (InductionBinOp &&
683 (InductionBinOp->getOpcode() == Instruction::FAdd ||
684 InductionBinOp->getOpcode() == Instruction::FSub))) &&
685 "Binary opcode should be specified for FP induction");
696 if (isa<SCEVConstant>(Step))
707 "Index type does not match StepValue type");
711 "Index type does not match StartValue type");
732 assert(isa<SCEVConstant>(Step) &&
733 "Expected constant step for pointer induction");
736 return B.
CreateGEP(
nullptr, StartValue, Index);
741 (InductionBinOp->
getOpcode() == Instruction::FAdd ||
742 InductionBinOp->
getOpcode() == Instruction::FSub) &&
743 "Original bin op should be defined for FP induction");
745 Value *StepValue = cast<SCEVUnknown>(Step)->getValue();
752 if (isa<Instruction>(MulExp))
754 cast<Instruction>(MulExp)->setFastMathFlags(Flags);
757 MulExp,
"induction");
758 if (isa<Instruction>(BOp))
759 cast<Instruction>(BOp)->setFastMathFlags(Flags);
783 Value *BEValue =
nullptr, *StartValue =
nullptr;
789 "Unexpected Phi node in the loop");
798 Value *Addend =
nullptr;
799 if (BOp->
getOpcode() == Instruction::FAdd) {
804 }
else if (BOp->
getOpcode() == Instruction::FSub)
812 if (
auto *
I = dyn_cast<Instruction>(Addend))
847 DEBUG(
dbgs() <<
"LV: PHI is not a poly recurrence.\n");
864 const SCEV *PhiScev = Expr ? Expr : SE->
getSCEV(Phi);
868 DEBUG(
dbgs() <<
"LV: PHI is not a poly recurrence.\n");
872 if (AR->
getLoop() != TheLoop) {
875 DEBUG(
dbgs() <<
"LV: PHI is a recurrence with respect to an outer loop.\n");
902 if (!PointerElementType->
isSized())
906 int64_t Size =
static_cast<int64_t
>(DL.
getTypeAllocSize(PointerElementType));
926 for (
auto &Inst : *Block) {
927 auto Users = Inst.users();
929 auto *
Use = cast<Instruction>(U);
1067 if (ExitBlocks.empty())
1089 "At least one edge out of the latch must go to the header");
1094 uint64_t TrueVal, FalseVal;
1098 if (!TrueVal || !FalseVal)
1104 return (TrueVal + (FalseVal / 2)) / FalseVal;
1106 return (FalseVal + (TrueVal / 2)) / TrueVal;
Legacy wrapper pass to provide the GlobalsAAResult object.
MaxMin_match< ICmpInst, LHS, RHS, umin_pred_ty > m_UMin(const LHS &L, const RHS &R)
BinaryOp_match< LHS, RHS, Instruction::And > m_And(const LHS &L, const RHS &R)
static bool isArithmeticRecurrenceKind(RecurrenceKind Kind)
Returns true if the recurrence kind is an arithmetic kind.
void push_back(const T &Elt)
A parsed version of the target data layout string in and methods for querying it. ...
IntegerType * getType() const
getType - Specialize the getType() method to always return an IntegerType, which reduces the amount o...
class_match< Value > m_Value()
Match an arbitrary value and ignore it.
Value * CreateICmp(CmpInst::Predicate P, Value *LHS, Value *RHS, const Twine &Name="")
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
BasicBlock::iterator GetInsertPoint() const
Value * CreateBinOp(Instruction::BinaryOps Opc, Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
static bool isFPInductionPHI(PHINode *Phi, const Loop *L, ScalarEvolution *SE, InductionDescriptor &D)
Returns true if Phi is a floating point induction in the loop L.
const SCEV * getConstant(ConstantInt *V)
This is the interface for a simple mod/ref and alias analysis over globals.
unsigned getNumOperands() const
Return number of MDNode operands.
The main scalar evolution driver.
int getConsecutiveDirection() const
Get the consecutive direction.
A global registry used in conjunction with static constructors to make pluggable components (like tar...
size_type count(PtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
static bool isReductionPHI(PHINode *Phi, Loop *TheLoop, RecurrenceDescriptor &RedDes)
Returns true if Phi is a reduction in TheLoop.
0 1 0 0 True if ordered and less than
const SCEV * getStepRecurrence(ScalarEvolution &SE) const
Constructs and returns the recurrence indicating how much this expression steps by.
bool isDoubleTy() const
Return true if this is 'double', a 64-bit IEEE fp type.
bool isLoopInvariant(const SCEV *S, const Loop *L)
Return true if the value of the given SCEV is unchanging in the specified loop.
const Function * getParent() const
Return the enclosing method, or null if none.
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
MaxMin_match< FCmpInst, LHS, RHS, ufmax_pred_ty > m_UnordFMax(const LHS &L, const RHS &R)
Match an 'unordered' floating point maximum function.
iv Induction Variable Users
static InstDesc isRecurrenceInstr(Instruction *I, RecurrenceKind Kind, InstDesc &Prev, bool HasFunNoNaNAttr)
Returns a struct describing if the instruction 'I' can be a recurrence variable of type 'Kind'...
const std::vector< BlockT * > & getBlocks() const
Get a list of the basic blocks which make up this loop.
bool isMinusOne() const
This function will return true iff every bit in this constant is set to true.
BlockT * getHeader() const
static Instruction * lookThroughAnd(PHINode *Phi, Type *&RT, SmallPtrSetImpl< Instruction * > &Visited, SmallPtrSetImpl< Instruction * > &CI)
Determines if Phi may have been type-promoted.
Type * getPointerElementType() const
BlockT * getLoopLatch() const
If there is a single latch block for this loop, return it.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
bool match(Val *V, const Pattern &P)
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
This is the interface for a SCEV-based alias analysis.
void initializeLoopPassPass(PassRegistry &)
Manually defined generic "LoopPass" dependency initialization.
This class represents the LLVM 'select' instruction.
struct fuzzer::@269 Flags
This is the base class for all instructions that perform data casts.
A Use represents the edge between a Value definition and its users.
static GCRegistry::Add< StatepointGC > D("statepoint-example","an example strategy for statepoint")
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool equals(StringRef RHS) const
equals - Check for string equality, this is more efficient than compare() when the relative ordering ...
static InstDesc isMinMaxSelectCmpPattern(Instruction *I, InstDesc &Prev)
Returns a struct describing if the instruction if the instruction is a Select(ICmp(X, Y), X, Y) instruction pattern corresponding to a min(X, Y) or max(X, Y).
Value * CreateAdd(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
MaxMin_match< FCmpInst, LHS, RHS, ufmin_pred_ty > m_UnordFMin(const LHS &L, const RHS &R)
Match an 'unordered' floating point minimum function.
ConstantInt * getConstIntStepValue() const
SmallVector< Instruction *, 8 > findDefsUsedOutsideOfLoop(Loop *L)
Returns the instructions that use values defined in the loop.
LLVM_NODISCARD bool empty() const
void getExitBlocks(SmallVectorImpl< BlockT * > &ExitBlocks) const
Return all of the successor blocks of this loop.
match_combine_or< LTy, RTy > m_CombineOr(const LTy &L, const RTy &R)
Combine two pattern matchers matching L || R.
Value * transform(IRBuilder<> &B, Value *Index, ScalarEvolution *SE, const DataLayout &DL) const
Compute the transformed value of Index at offset StartValue using step StepValue. ...
This node represents a polynomial recurrence on the trip count of the specified loop.
bool isHalfTy() const
Return true if this is 'half', a 16-bit IEEE fp type.
This instruction compares its operands according to the predicate given to the constructor.
BasicBlock * getSuccessor(unsigned i) const
MaxMin_match< FCmpInst, LHS, RHS, ofmin_pred_ty > m_OrdFMin(const LHS &L, const RHS &R)
Match an 'ordered' floating point minimum function.
bool hasUnsafeAlgebra() const
Determine whether the unsafe-algebra flag is set.
MaxMin_match< ICmpInst, LHS, RHS, smin_pred_ty > m_SMin(const LHS &L, const RHS &R)
static bool areAllUsesIn(Instruction *I, SmallPtrSetImpl< Instruction * > &Set)
Returns true if all uses of the instruction I is within the Set.
const SCEVAddRecExpr * getAsAddRec(Value *V)
Attempts to produce an AddRecExpr for V by adding additional SCEV predicates.
bool isFloatingPointTy() const
Return true if this is one of the six floating-point types.
AnalysisUsage & addPreservedID(const void *ID)
Value * CreateSub(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
Not an induction variable.
static GCRegistry::Add< OcamlGC > B("ocaml","ocaml 3.10-compatible GC")
This POD struct holds information about a potential recurrence operation.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
static bool hasMultipleUsesOf(Instruction *I, SmallPtrSetImpl< Instruction * > &Insts)
Returns true if instruction I has multiple uses in Insts.
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
unsigned getNumIncomingValues() const
Return the number of incoming edges.
Pointer induction var. Step = C / sizeof(elem).
const SCEV * getSCEV(Value *V)
Returns the SCEV expression of V, in the context of the current SCEV predicate.
static bool AddReductionVar(PHINode *Phi, RecurrenceKind Kind, Loop *TheLoop, bool HasFunNoNaNAttr, RecurrenceDescriptor &RedDes)
Returns true if Phi is a reduction of type Kind and adds it to the RecurrenceDescriptor.
Value * CreateFCmp(CmpInst::Predicate P, Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
bool isSized(SmallPtrSetImpl< Type * > *Visited=nullptr) const
Return true if it makes sense to take the size of this type.
Integer induction variable. Step = C.
MaxMin_match< ICmpInst, LHS, RHS, umax_pred_ty > m_UMax(const LHS &L, const RHS &R)
* if(!EatIfPresent(lltok::kw_thread_local)) return false
ParseOptionalThreadLocal := /*empty.
apint_match m_APInt(const APInt *&Res)
Match a ConstantInt or splatted ConstantVector, binding the specified pointer to the contained APInt...
BlockT * getLoopPreheader() const
If there is a preheader for this loop, return it.
LLVM Basic Block Representation.
The instances of the Type class are immutable: once they are created, they are never changed...
Type * getType() const
Return the LLVM type of this SCEV expression.
Conditional or Unconditional Branch instruction.
This is an important base class in LLVM.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
Value * CreateSelect(Value *C, Value *True, Value *False, const Twine &Name="", Instruction *MDFrom=nullptr)
bool isFloatTy() const
Return true if this is 'float', a 32-bit IEEE fp type.
APInt Or(const APInt &LHS, const APInt &RHS)
Bitwise OR function for APInt.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
APInt Xor(const APInt &LHS, const APInt &RHS)
Bitwise XOR function for APInt.
bool extractProfMetadata(uint64_t &TrueVal, uint64_t &FalseVal) const
Retrieve the raw weight values of a conditional branch or select.
MDNode * getLoopID() const
Return the llvm.loop loop id metadata node for this loop if it is present.
Represent the analysis usage information of a pass.
BasicBlock * getIncomingBlock(unsigned i) const
Return incoming basic block number i.
bool contains(const LoopT *L) const
Return true if the specified loop is contained within in this loop.
Instruction * getUnsafeAlgebraInst()
bool any_of(R &&Range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly...
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Value * expandCodeFor(const SCEV *SH, Type *Ty, Instruction *I)
Insert code to directly compute the specified SCEV expression into the program.
static bool isFirstOrderRecurrence(PHINode *Phi, Loop *TheLoop, DominatorTree *DT)
Returns true if Phi is a first-order recurrence.
BlockT * getExitingBlock() const
If getExitingBlocks would return exactly one block, return that block.
Value * getOperand(unsigned i) const
bool isCommutative() const
Return true if the instruction is commutative:
Optional< unsigned > getLoopEstimatedTripCount(Loop *L)
Get a loop's estimated trip count based on branch weight metadata.
Type * getSrcTy() const
Return the source type, as a convenience.
void append(in_iter in_start, in_iter in_end)
Add the specified range to the end of the SmallVector.
bool isPointerTy() const
True if this is an instance of PointerType.
LLVMContext & getContext() const
All values hold a context through their type.
Optional< const MDOperand * > findStringMetadataForLoop(Loop *TheLoop, StringRef Name)
Find string metadata for loop.
static unsigned getRecurrenceBinOp(RecurrenceKind Kind)
Returns the opcode of binary operation corresponding to the RecurrenceKind.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
bool dominates(const Instruction *Def, const Use &U) const
Return true if Def dominates a use in User.
The RecurrenceDescriptor is used to identify recurrences variables in a loop.
0 0 1 0 True if ordered and greater than
BinaryOps getOpcode() const
StringRef getString() const
static IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
const MDOperand & getOperand(unsigned I) const
MinMaxRecurrenceKind getMinMaxKind()
Legacy wrapper pass to provide the SCEVAAResult object.
This is the shared class of boolean and integer constants.
A struct for saving information about induction variables.
Value * getIncomingValue(unsigned i) const
Return incoming value number x.
uint64_t getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
AnalysisUsage & addRequiredID(const void *ID)
const Module * getModule() const
Return the module owning the function this instruction belongs to or nullptr it the function does not...
static bool getSourceExtensionKind(Instruction *Start, Instruction *Exit, Type *RT, bool &IsSigned, SmallPtrSetImpl< Instruction * > &Visited, SmallPtrSetImpl< Instruction * > &CI)
Returns true if all the source operands of a recurrence are either SExtInsts or ZExtInsts.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Module.h This file contains the declarations for the Module class.
Type * getType() const
All values are typed, get the type of this value.
static bool isFloatingPointRecurrenceKind(RecurrenceKind Kind)
Returns true if the recurrence kind is a floating point kind.
An interface layer with SCEV used to manage how we see SCEV expressions for values in the context of ...
LLVM_NODISCARD T pop_back_val()
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.
ConstantInt * getValue() const
static Constant * get(Type *Ty, double V)
This returns a ConstantFP, or a vector containing a splat of a ConstantFP, for the specified value in...
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
static Constant * getRecurrenceIdentity(RecurrenceKind K, Type *Tp)
Returns identity corresponding to the RecurrenceKind.
Value * CreateGEP(Value *Ptr, ArrayRef< Value * > IdxList, const Twine &Name="")
Class for arbitrary precision integers.
Value * getIncomingValueForBlock(const BasicBlock *BB) const
bool isIntegerTy() const
True if this is an instance of IntegerType.
iterator_range< user_iterator > users()
static Value * createMinMaxOp(IRBuilder<> &Builder, MinMaxRecurrenceKind RK, Value *Left, Value *Right)
Returns a Min/Max operation corresponding to MinMaxRecurrenceKind.
This class uses information about analyze scalars to rewrite expressions in canonical form...
const SCEV * getAddExpr(SmallVectorImpl< const SCEV * > &Ops, SCEV::NoWrapFlags Flags=SCEV::FlagAnyWrap)
Get a canonical add expression, or something simpler if possible.
APInt And(const APInt &LHS, const APInt &RHS)
Bitwise AND function for APInt.
static bool isZero(Value *V, const DataLayout &DL, DominatorTree *DT, AssumptionCache *AC)
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
Captures loop safety information.
This class represents an analyzed expression in the program.
unsigned getNumSuccessors() const
static bool isIntegerRecurrenceKind(RecurrenceKind Kind)
Returns true if the recurrence kind is an integer kind.
Floating point induction variable.
Represents a single loop in the control flow graph.
ScalarEvolution * getSE() const
Returns the ScalarEvolution analysis used.
bool hasOneUse() const
Return true if there is exactly one user of this value.
MaxMin_match< ICmpInst, LHS, RHS, smax_pred_ty > m_SMax(const LHS &L, const RHS &R)
void getLoopAnalysisUsage(AnalysisUsage &AU)
Helper to consistently add the set of standard passes to a loop pass's AnalysisUsage.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
const Loop * getLoop() const
InductionDescriptor()
Default constructor - creates an invalid induction.
StringRef getValueAsString() const
Return the attribute's value as a string.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
user_iterator user_begin()
MaxMin_match< FCmpInst, LHS, RHS, ofmax_pred_ty > m_OrdFMax(const LHS &L, const RHS &R)
Match an 'ordered' floating point maximum function.
unsigned getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
LLVM Value Representation.
const SCEV * getSCEV(Value *V)
Return a SCEV expression for the full generality of the specified expression.
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
void setFastMathFlags(FastMathFlags NewFMF)
Set the fast-math flags to be used with generated fp-math operators.
const SCEV * getUnknown(Value *V)
The legacy pass manager's analysis pass to compute loop information.
Convenience struct for specifying and reasoning about fast-math flags.
StringRef - Represent a constant reference to a string, i.e.
This is the interface for LLVM's primary stateless and local alias analysis.
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
Legacy analysis pass which computes a DominatorTree.
A wrapper pass to provide the legacy pass manager access to a suitably prepared AAResults object...
Value * CreateFMul(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
int64_t getSExtValue() const
Return the constant as a 64-bit integer value after it has been sign extended as appropriate for the ...
bool isGuaranteedToExecute(const Instruction &Inst, const DominatorTree *DT, const Loop *CurLoop, const LoopSafetyInfo *SafetyInfo)
Returns true if the instruction in a loop is guaranteed to execute at least once. ...
const SCEV * getMulExpr(SmallVectorImpl< const SCEV * > &Ops, SCEV::NoWrapFlags Flags=SCEV::FlagAnyWrap)
Get a canonical multiply expression, or something simpler if possible.
int getBasicBlockIndex(const BasicBlock *BB) const
Return the first index of the specified basic block in the value list for this PHI.
const BasicBlock * getParent() const
static bool isInductionPHI(PHINode *Phi, const Loop *L, ScalarEvolution *SE, InductionDescriptor &D, const SCEV *Expr=nullptr)
Returns true if Phi is an induction in the loop L.
bool isOne() const
This is just a convenience method to make client code smaller for a common case.
bind_ty< Instruction > m_Instruction(Instruction *&I)
Match an instruction, capturing it if we match.
RecurrenceKind
This enum represents the kinds of recurrences that we support.
This class represents a constant integer value.
Legacy wrapper pass to provide the BasicAAResult object.
bool is_contained(R &&Range, const E &Element)
Wrapper function around std::find to detect if an element exists in a container.