40 #define DEBUG_TYPE "iv-descriptors" 45 if (!Set.
count(dyn_cast<Instruction>(*
Use)))
59 case RK_IntegerMinMax:
66 return (Kind != RK_NoRecurrence) && !isIntegerRecurrenceKind(Kind);
92 const APInt *M =
nullptr;
98 int32_t
Bits = (*M + 1).exactLogBase2();
115 bool IsSigned =
false;
126 MaxBitWidth =
Mask.getBitWidth() -
Mask.countLeadingZeros();
135 MaxBitWidth = NumTypeBits - NumSignBits;
161 Type *RecurrenceType,
168 while (!Worklist.
empty()) {
171 if (
auto *Cast = dyn_cast<CastInst>(Val))
172 if (Cast->getSrcTy() == RecurrenceType) {
182 for (
Value *
O : cast<User>(Val)->operands())
183 if (
auto *
I = dyn_cast<Instruction>(
O))
190 Loop *TheLoop,
bool HasFunNoNaNAttr,
212 bool FoundReduxOp =
false;
218 bool FoundStartPHI =
false;
223 unsigned NumCmpSelectPatternInst = 0;
230 bool IsSigned =
false;
241 if (!isFloatingPointRecurrenceKind(Kind))
244 if (!isIntegerRecurrenceKind(Kind))
246 if (isArithmeticRecurrenceKind(Kind))
247 Start =
lookThroughAnd(Phi, RecurrenceType, VisitedInsts, CastInsts);
251 VisitedInsts.
insert(Start);
272 while (!Worklist.
empty()) {
282 bool IsAPhi = isa<PHINode>(Cur);
290 if (!Cur->
isCommutative() && !IsAPhi && !isa<SelectInst>(Cur) &&
291 !isa<ICmpInst>(Cur) && !isa<FCmpInst>(Cur) &&
299 ReduxDesc = isRecurrenceInstr(Cur, Kind, ReduxDesc, HasFunNoNaNAttr);
307 bool IsASelect = isa<SelectInst>(Cur);
311 if (IsASelect && (Kind == RK_FloatAdd || Kind == RK_FloatMult) &&
312 hasMultipleUsesOf(Cur, VisitedInsts, 2))
316 if (!IsAPhi && !IsASelect && Kind != RK_IntegerMinMax &&
317 Kind != RK_FloatMinMax && hasMultipleUsesOf(Cur, VisitedInsts, 1))
321 if (IsAPhi && Cur != Phi && !areAllUsesIn(Cur, VisitedInsts))
324 if (Kind == RK_IntegerMinMax &&
325 (isa<ICmpInst>(Cur) || isa<SelectInst>(Cur)))
326 ++NumCmpSelectPatternInst;
327 if (Kind == RK_FloatMinMax && (isa<FCmpInst>(Cur) || isa<SelectInst>(Cur)))
328 ++NumCmpSelectPatternInst;
331 FoundReduxOp |= !IsAPhi && Cur != Start;
346 if (ExitInstruction == Cur)
353 if (ExitInstruction !=
nullptr || Cur == Phi)
362 ExitInstruction = Cur;
369 InstDesc IgnoredVal(
false,
nullptr);
370 if (VisitedInsts.
insert(UI).second) {
371 if (isa<PHINode>(UI))
375 }
else if (!isa<PHINode>(UI) &&
376 ((!isa<FCmpInst>(UI) && !isa<ICmpInst>(UI) &&
377 !isa<SelectInst>(UI)) ||
378 (!isConditionalRdxPattern(Kind, UI).isRecurrence() &&
379 !isMinMaxSelectCmpPattern(UI, IgnoredVal).isRecurrence())))
384 FoundStartPHI =
true;
392 if ((Kind == RK_IntegerMinMax || Kind == RK_FloatMinMax) &&
393 NumCmpSelectPatternInst != 2)
396 if (!FoundStartPHI || !FoundReduxOp || !ExitInstruction)
425 std::tie(ComputedType, IsSigned) =
427 if (ComputedType != RecurrenceType)
450 RdxStart, ExitInstruction, Kind, FMF, ReduxDesc.
getMinMaxKind(),
462 assert((isa<ICmpInst>(I) || isa<FCmpInst>(I) || isa<SelectInst>(I)) &&
463 "Expect a select instruction");
469 if ((Cmp = dyn_cast<ICmpInst>(I)) || (Cmp = dyn_cast<FCmpInst>(I))) {
476 if (!(Select = dyn_cast<SelectInst>(I)))
478 if (!(Cmp = dyn_cast<ICmpInst>(I->
getOperand(0))) &&
489 return InstDesc(Select, MRK_UIntMin);
491 return InstDesc(Select, MRK_UIntMax);
493 return InstDesc(Select, MRK_SIntMax);
495 return InstDesc(Select, MRK_SIntMin);
497 return InstDesc(Select, MRK_FloatMin);
499 return InstDesc(Select, MRK_FloatMax);
501 return InstDesc(Select, MRK_FloatMin);
503 return InstDesc(Select, MRK_FloatMax);
533 if ((isa<PHINode>(*TrueVal) && isa<PHINode>(*FalseVal)) ||
534 (!isa<PHINode>(*TrueVal) && !isa<PHINode>(*FalseVal)))
539 : dyn_cast<Instruction>(TrueVal);
547 return InstDesc(Kind == RK_FloatAdd, SI);
550 return InstDesc(Kind == RK_FloatMult, SI);
557 InstDesc &Prev,
bool HasFunNoNaNAttr) {
565 case Instruction::PHI:
567 case Instruction::Sub:
569 return InstDesc(Kind == RK_IntegerAdd, I);
570 case Instruction::Mul:
571 return InstDesc(Kind == RK_IntegerMult, I);
572 case Instruction::And:
573 return InstDesc(Kind == RK_IntegerAnd, I);
574 case Instruction::Or:
575 return InstDesc(Kind == RK_IntegerOr, I);
576 case Instruction::Xor:
577 return InstDesc(Kind == RK_IntegerXor, I);
578 case Instruction::FMul:
579 return InstDesc(Kind == RK_FloatMult, I, UAI);
580 case Instruction::FSub:
581 case Instruction::FAdd:
582 return InstDesc(Kind == RK_FloatAdd, I, UAI);
584 if (Kind == RK_FloatAdd || Kind == RK_FloatMult)
585 return isConditionalRdxPattern(Kind, I);
587 case Instruction::FCmp:
588 case Instruction::ICmp:
589 if (Kind != RK_IntegerMinMax &&
590 (!HasFunNoNaNAttr || Kind != RK_FloatMinMax))
592 return isMinMaxSelectCmpPattern(I, Prev);
598 unsigned MaxNumUses) {
599 unsigned NumUses = 0;
602 if (Insts.
count(dyn_cast<Instruction>(*
Use)))
604 if (NumUses > MaxNumUses)
617 bool HasFunNoNaNAttr =
620 if (AddReductionVar(Phi, RK_IntegerAdd, TheLoop, HasFunNoNaNAttr, RedDes, DB,
622 LLVM_DEBUG(
dbgs() <<
"Found an ADD reduction PHI." << *Phi <<
"\n");
625 if (AddReductionVar(Phi, RK_IntegerMult, TheLoop, HasFunNoNaNAttr, RedDes, DB,
627 LLVM_DEBUG(
dbgs() <<
"Found a MUL reduction PHI." << *Phi <<
"\n");
630 if (AddReductionVar(Phi, RK_IntegerOr, TheLoop, HasFunNoNaNAttr, RedDes, DB,
632 LLVM_DEBUG(
dbgs() <<
"Found an OR reduction PHI." << *Phi <<
"\n");
635 if (AddReductionVar(Phi, RK_IntegerAnd, TheLoop, HasFunNoNaNAttr, RedDes, DB,
637 LLVM_DEBUG(
dbgs() <<
"Found an AND reduction PHI." << *Phi <<
"\n");
640 if (AddReductionVar(Phi, RK_IntegerXor, TheLoop, HasFunNoNaNAttr, RedDes, DB,
642 LLVM_DEBUG(
dbgs() <<
"Found a XOR reduction PHI." << *Phi <<
"\n");
645 if (AddReductionVar(Phi, RK_IntegerMinMax, TheLoop, HasFunNoNaNAttr, RedDes,
647 LLVM_DEBUG(
dbgs() <<
"Found a MINMAX reduction PHI." << *Phi <<
"\n");
650 if (AddReductionVar(Phi, RK_FloatMult, TheLoop, HasFunNoNaNAttr, RedDes, DB,
652 LLVM_DEBUG(
dbgs() <<
"Found an FMult reduction PHI." << *Phi <<
"\n");
655 if (AddReductionVar(Phi, RK_FloatAdd, TheLoop, HasFunNoNaNAttr, RedDes, DB,
657 LLVM_DEBUG(
dbgs() <<
"Found an FAdd reduction PHI." << *Phi <<
"\n");
660 if (AddReductionVar(Phi, RK_FloatMinMax, TheLoop, HasFunNoNaNAttr, RedDes, DB,
662 LLVM_DEBUG(
dbgs() <<
"Found an float MINMAX reduction PHI." << *Phi
683 if (!Preheader || !Latch)
694 if (!Previous || !TheLoop->
contains(Previous) || isa<PHINode>(Previous) ||
695 SinkAfter.
count(Previous))
727 if (SinkAfter.
find(I) != SinkAfter.
end())
736 allUsesDominatedBy(I, Previous)) {
737 SinkAfter[
I] = Previous;
742 return allUsesDominatedBy(Phi, Previous);
778 return Instruction::Mul;
780 return Instruction::Or;
782 return Instruction::And;
784 return Instruction::Xor;
786 return Instruction::FMul;
788 return Instruction::FAdd;
789 case RK_IntegerMinMax:
790 return Instruction::ICmp;
792 return Instruction::FCmp;
801 : StartValue(Start), IK(K), Step(Step), InductionBinOp(BOp) {
802 assert(IK != IK_NoInduction &&
"Not an induction");
806 assert(StartValue &&
"StartValue is null");
807 assert((IK != IK_PtrInduction || StartValue->getType()->isPointerTy()) &&
808 "StartValue is not a pointer for pointer induction");
809 assert((IK != IK_IntInduction || StartValue->getType()->isIntegerTy()) &&
810 "StartValue is not an integer for integer induction");
813 assert((!getConstIntStepValue() || !getConstIntStepValue()->
isZero()) &&
814 "Step value is zero");
816 assert((IK != IK_PtrInduction || getConstIntStepValue()) &&
817 "Step value should be constant for pointer induction");
819 "StepValue is not an integer");
822 "StepValue is not FP for FpInduction");
823 assert((IK != IK_FpInduction ||
825 (InductionBinOp->getOpcode() == Instruction::FAdd ||
826 InductionBinOp->getOpcode() == Instruction::FSub))) &&
827 "Binary opcode should be specified for FP induction");
830 for (
auto &Inst : *Casts) {
831 RedundantCasts.push_back(Inst);
844 if (isa<SCEVConstant>(Step))
863 Value *BEValue =
nullptr, *StartValue =
nullptr;
869 "Unexpected Phi node in the loop");
878 Value *Addend =
nullptr;
879 if (BOp->
getOpcode() == Instruction::FAdd) {
884 }
else if (BOp->
getOpcode() == Instruction::FSub)
892 if (
auto *
I = dyn_cast<Instruction>(Addend))
939 assert(CastInsts.
empty() &&
"CastInsts is expected to be empty.");
940 auto *PN = cast<PHINode>(PhiScev->
getValue());
941 assert(PSE.
getSCEV(PN) == AR &&
"Unexpected phi node SCEV expression");
952 auto getDef = [&](
const Value *Val) ->
Value * {
959 if (L->isLoopInvariant(Op0))
961 else if (L->isLoopInvariant(Op1))
971 Value *Val = PN->getIncomingValueForBlock(Latch);
979 bool InCastSequence =
false;
984 if (!Inst || !L->contains(Inst)) {
989 InCastSequence =
true;
990 if (InCastSequence) {
993 if (!CastInsts.
empty())
994 if (!Inst->hasOneUse())
1004 return InCastSequence;
1021 return isFPInductionPHI(Phi, TheLoop, PSE.
getSE(),
D);
1042 if (PhiScev != AR && SymbolicPhi) {
1045 return isInductionPHI(Phi, TheLoop, PSE.
getSE(),
D, AR, &Casts);
1048 return isInductionPHI(Phi, TheLoop, PSE.
getSE(),
D, AR);
1061 const SCEV *PhiScev = Expr ? Expr : SE->
getSCEV(Phi);
1069 if (AR->
getLoop() != TheLoop) {
1073 dbgs() <<
"LV: PHI is a recurrence with respect to an outer loop.\n");
1108 if (!PointerElementType->
isSized())
MaxMin_match< ICmpInst, LHS, RHS, umin_pred_ty > m_UMin(const LHS &L, const RHS &R)
void computeKnownBits(const Value *V, KnownBits &Known, const DataLayout &DL, unsigned Depth=0, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr, OptimizationRemarkEmitter *ORE=nullptr, bool UseInstrInfo=true)
Determine which bits of V are known to be either zero or one and return them in the KnownZero/KnownOn...
static bool isArithmeticRecurrenceKind(RecurrenceKind Kind)
Returns true if the recurrence kind is an arithmetic kind.
IntegerType * getType() const
getType - Specialize the getType() method to always return an IntegerType, which reduces the amount o...
A parsed version of the target data layout string in and methods for querying it. ...
class_match< Value > m_Value()
Match an arbitrary value and ignore it.
This class is the base class for the comparison instructions.
iterator_range< use_iterator > uses()
BlockT * getLoopLatch() const
If there is a single latch block for this loop, return it.
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.
Instruction * getPatternInst()
InductionDescriptor()=default
Default constructor - creates an invalid induction.
const SCEV * getConstant(ConstantInt *V)
This class represents lattice values for constants.
BinaryOps getOpcode() const
BinaryOp_match< LHS, RHS, Instruction::FAdd > m_FAdd(const LHS &L, const RHS &R)
This is the interface for a simple mod/ref and alias analysis over globals.
static bool isInductionPHI(PHINode *Phi, const Loop *L, ScalarEvolution *SE, InductionDescriptor &D, const SCEV *Expr=nullptr, SmallVectorImpl< Instruction *> *CastsToIgnore=nullptr)
Returns true if Phi is an induction in the loop L.
bool isSized(SmallPtrSetImpl< Type *> *Visited=nullptr) const
Return true if it makes sense to take the size of this type.
int getConsecutiveDirection() const
Get the consecutive direction.
ConstantInt * getConstIntStepValue() const
void push_back(const T &Elt)
static bool AddReductionVar(PHINode *Phi, RecurrenceKind Kind, Loop *TheLoop, bool HasFunNoNaNAttr, RecurrenceDescriptor &RedDes, DemandedBits *DB=nullptr, AssumptionCache *AC=nullptr, DominatorTree *DT=nullptr)
Returns true if Phi is a reduction of type Kind and adds it to the RecurrenceDescriptor.
The main scalar evolution driver.
BlockT * getLoopPreheader() const
If there is a preheader for this loop, return it.
const Value * getTrueValue() const
A cache of @llvm.assume calls within a function.
LLVMContext & getContext() const
All values hold a context through their type.
bool isLoopInvariant(const SCEV *S, const Loop *L)
Return true if the value of the given SCEV is unchanging in the specified loop.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly...
BinaryOp_match< LHS, RHS, Instruction::FSub > m_FSub(const LHS &L, const RHS &R)
MaxMin_match< FCmpInst, LHS, RHS, ufmax_pred_ty > m_UnordFMax(const LHS &L, const RHS &R)
Match an 'unordered' floating point maximum function.
TypeSize getTypeSizeInBits(Type *Ty) const
Size examples:
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...
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'...
static bool hasMultipleUsesOf(Instruction *I, SmallPtrSetImpl< Instruction *> &Insts, unsigned MaxNumUses)
Returns true if instruction I has multiple uses in Insts.
bool match(Val *V, const Pattern &P)
This is the interface for a SCEV-based alias analysis.
static FastMathFlags getFast()
This class represents the LLVM 'select' instruction.
Type * getPointerElementType() const
const Loop * getLoop() const
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
int getBasicBlockIndex(const BasicBlock *BB) const
Return the first index of the specified basic block in the value list for this PHI.
bool isFloatingPointTy() const
Return true if this is one of the six floating-point types.
static Instruction * lookThroughAnd(PHINode *Phi, Type *&RT, SmallPtrSetImpl< Instruction *> &Visited, SmallPtrSetImpl< Instruction *> &CI)
Determines if Phi may have been type-promoted.
A Use represents the edge between a Value definition and its users.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
bool isIntegerTy() const
True if this is an instance of IntegerType.
static bool areAllUsesIn(Instruction *I, SmallPtrSetImpl< Instruction *> &Set)
Returns true if all uses of the instruction I is within the Set.
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).
static bool getCastsForInductionPHI(PredicatedScalarEvolution &PSE, const SCEVUnknown *PhiScev, const SCEVAddRecExpr *AR, SmallVectorImpl< Instruction *> &CastInsts)
This function is called when we suspect that the update-chain of a phi node (whose symbolic SCEV expr...
MaxMin_match< FCmpInst, LHS, RHS, ufmin_pred_ty > m_UnordFMin(const LHS &L, const RHS &R)
Match an 'unordered' floating point minimum function.
Contains a collection of routines for determining if a given instruction is guaranteed to execute if ...
BlockT * getHeader() const
ConstantInt * getValue() const
bool isOne() const
This is just a convenience method to make client code smaller for a common case.
FastMathFlags getFastMathFlags() const
Convenience function for getting all the fast-math flags, which must be an operator which supports th...
Type * getType() const
All values are typed, get the type of this value.
This node represents a polynomial recurrence on the trip count of the specified loop.
This instruction compares its operands according to the predicate given to the constructor.
MaxMin_match< FCmpInst, LHS, RHS, ofmin_pred_ty > m_OrdFMin(const LHS &L, const RHS &R)
Match an 'ordered' floating point minimum function.
MaxMin_match< ICmpInst, LHS, RHS, smin_pred_ty > m_SMin(const LHS &L, const RHS &R)
const SCEVAddRecExpr * getAsAddRec(Value *V)
Attempts to produce an AddRecExpr for V by adding additional SCEV predicates.
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
static std::pair< Type *, bool > computeRecurrenceType(Instruction *Exit, DemandedBits *DB, AssumptionCache *AC, DominatorTree *DT)
Compute the minimal bit width needed to represent a reduction whose exit instruction is given by Exit...
bool isMinusOne() const
This function will return true iff every bit in this constant is set to true.
This POD struct holds information about a potential recurrence operation.
const SCEV * getStepRecurrence(ScalarEvolution &SE) const
Constructs and returns the recurrence indicating how much this expression steps by.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
Value * getOperand(unsigned i) const
const SCEV * getSCEV(Value *V)
Returns the SCEV expression of V, in the context of the current SCEV predicate.
iterator find(const_arg_type_t< KeyT > Val)
bool isNegative() const
Returns true if this value is known to be negative.
bool isFloatTy() const
Return true if this is 'float', a 32-bit IEEE fp type.
unsigned ComputeNumSignBits(const Value *Op, const DataLayout &DL, unsigned Depth=0, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr, bool UseInstrInfo=true)
Return the number of times the sign bit of the register is replicated into the other bits...
This means that we are dealing with an entirely unknown SCEV value, and only represent it as its LLVM...
MaxMin_match< ICmpInst, LHS, RHS, umax_pred_ty > m_UMax(const LHS &L, const RHS &R)
apint_match m_APInt(const APInt *&Res)
Match a ConstantInt or splatted ConstantVector, binding the specified pointer to the contained APInt...
LLVM Basic Block Representation.
The instances of the Type class are immutable: once they are created, they are never changed...
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This is an important base class in LLVM.
Value * getIncomingValueForBlock(const BasicBlock *BB) const
bool isPointerTy() const
True if this is an instance of PointerType.
BinaryOp_match< LHS, RHS, Instruction::And, true > m_c_And(const LHS &L, const RHS &R)
Matches an And with LHS and RHS in either order.
TypeSize getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
bool mayHaveSideEffects() const
Return true if the instruction may have side effects.
constexpr bool isPowerOf2_64(uint64_t Value)
Return true if the argument is a power of two > 0 (64 bit edition.)
bool isFast() const
Determine whether all fast-math-flags are set.
Instruction * getUnsafeAlgebraInst()
bool isHalfTy() const
Return true if this is 'half', a 16-bit IEEE fp type.
bool areAddRecsEqualWithPreds(const SCEVAddRecExpr *AR1, const SCEVAddRecExpr *AR2) const
Check if AR1 and AR2 are equal, while taking into account Equal predicates in Preds.
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
static bool isReductionPHI(PHINode *Phi, Loop *TheLoop, RecurrenceDescriptor &RedDes, DemandedBits *DB=nullptr, AssumptionCache *AC=nullptr, DominatorTree *DT=nullptr)
Returns true if Phi is a reduction in TheLoop.
const Value * getCondition() const
static InstDesc isConditionalRdxPattern(RecurrenceKind Kind, Instruction *I)
Returns a struct describing if the instruction is a Select(FCmp(X, Y), (Z = X op PHINode), PHINode) instruction pattern.
uint64_t NextPowerOf2(uint64_t A)
Returns the next power of two (in 64-bits) that is strictly greater than A.
ScalarEvolution * getSE() const
Returns the ScalarEvolution analysis used.
Value * getIncomingValue(unsigned i) const
Return incoming value number x.
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.
static bool isFirstOrderRecurrence(PHINode *Phi, Loop *TheLoop, DenseMap< Instruction *, Instruction *> &SinkAfter, DominatorTree *DT)
Returns true if Phi is a first-order recurrence.
The RecurrenceDescriptor is used to identify recurrences variables in a loop.
static IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
bool contains(const LoopT *L) const
Return true if the specified loop is contained within in this loop.
MinMaxRecurrenceKind getMinMaxKind()
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
This is the shared class of boolean and integer constants.
Type * getType() const
Return the LLVM type of this SCEV expression.
A struct for saving information about induction variables.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
bool dominates(const Instruction *Def, const Use &U) const
Return true if Def dominates a use in User.
Module.h This file contains the declarations for the Module class.
Instruction * user_back()
Specialize the methods defined in Value, as we know that an instruction can only be used by other ins...
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 IntegerType * getIntNTy(LLVMContext &C, unsigned N)
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
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.
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...
unsigned getNumIncomingValues() const
Return the number of incoming edges.
BinaryOp_match< LHS, RHS, Instruction::FMul > m_FMul(const LHS &L, const RHS &R)
APInt getDemandedBits(Instruction *I)
Return the bits demanded from instruction I.
bool isCommutative() const
Return true if the instruction is commutative:
static void collectCastsToIgnore(Loop *TheLoop, Instruction *Exit, Type *RecurrenceType, SmallPtrSetImpl< Instruction *> &Casts)
Collect cast instructions that can be ignored in the vectorizer's cost model, given a reduction exit ...
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.
const Module * getModule() const
Return the module owning the function this instruction belongs to or nullptr it the function does not...
Class for arbitrary precision integers.
iterator_range< user_iterator > users()
const Value * getFalseValue() const
void append(in_iter in_start, in_iter in_end)
Add the specified range to the end of the SmallVector.
static bool isZero(Value *V, const DataLayout &DL, DominatorTree *DT, AssumptionCache *AC)
This class represents an analyzed expression in the program.
static bool isIntegerRecurrenceKind(RecurrenceKind Kind)
Returns true if the recurrence kind is an integer kind.
LLVM_NODISCARD bool empty() const
StringRef getValueAsString() const
Return the attribute's value as a string.
Represents a single loop in the control flow graph.
BasicBlock * getIncomingBlock(unsigned i) const
Return incoming basic block number i.
const Function * getParent() const
Return the enclosing method, or null if none.
MaxMin_match< ICmpInst, LHS, RHS, smax_pred_ty > m_SMax(const LHS &L, const RHS &R)
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
size_type count(const_arg_type_t< KeyT > Val) const
Return 1 if the specified key is in the map, 0 otherwise.
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.
LLVM Value Representation.
const SCEV * getSCEV(Value *V)
Return a SCEV expression for the full generality of the specified expression.
bool hasAllowReassoc() const
Determine whether the allow-reassociation flag is set.
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
const SCEV * getUnknown(Value *V)
bool hasOneUse() const
Return true if there is exactly one user of this value.
Convenience struct for specifying and reasoning about fast-math flags.
This is the interface for LLVM's primary stateless and local alias analysis.
bool isNonNegative() const
Returns true if this value is known to be non-negative.
int64_t getSExtValue() const
Return the constant as a 64-bit integer value after it has been sign extended as appropriate for the ...
bool isDoubleTy() const
Return true if this is 'double', a 64-bit IEEE fp type.
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.
const BasicBlock * getParent() const
This class represents a constant integer value.
bool is_contained(R &&Range, const E &Element)
Wrapper function around std::find to detect if an element exists in a container.