42 #define DEBUG_TYPE "iv-descriptors" 47 if (!Set.
count(dyn_cast<Instruction>(*
Use)))
61 case RK_IntegerMinMax:
68 return (Kind != RK_NoRecurrence) && !isIntegerRecurrenceKind(Kind);
94 const APInt *M =
nullptr;
100 int32_t
Bits = (*M + 1).exactLogBase2();
117 bool IsSigned =
false;
128 MaxBitWidth =
Mask.getBitWidth() -
Mask.countLeadingZeros();
137 MaxBitWidth = NumTypeBits - NumSignBits;
163 Type *RecurrenceType,
170 while (!Worklist.
empty()) {
173 if (
auto *Cast = dyn_cast<CastInst>(Val))
174 if (Cast->getSrcTy() == RecurrenceType) {
184 for (
Value *
O : cast<User>(Val)->operands())
185 if (
auto *
I = dyn_cast<Instruction>(
O))
192 Loop *TheLoop,
bool HasFunNoNaNAttr,
214 bool FoundReduxOp =
false;
220 bool FoundStartPHI =
false;
225 unsigned NumCmpSelectPatternInst = 0;
232 bool IsSigned =
false;
243 if (!isFloatingPointRecurrenceKind(Kind))
246 if (!isIntegerRecurrenceKind(Kind))
248 if (isArithmeticRecurrenceKind(Kind))
249 Start =
lookThroughAnd(Phi, RecurrenceType, VisitedInsts, CastInsts);
253 VisitedInsts.
insert(Start);
270 while (!Worklist.
empty()) {
280 bool IsAPhi = isa<PHINode>(Cur);
288 if (!Cur->
isCommutative() && !IsAPhi && !isa<SelectInst>(Cur) &&
289 !isa<ICmpInst>(Cur) && !isa<FCmpInst>(Cur) &&
297 ReduxDesc = isRecurrenceInstr(Cur, Kind, ReduxDesc, HasFunNoNaNAttr);
302 bool IsASelect = isa<SelectInst>(Cur);
306 if (IsASelect && (Kind == RK_FloatAdd || Kind == RK_FloatMult) &&
307 hasMultipleUsesOf(Cur, VisitedInsts, 2))
311 if (!IsAPhi && !IsASelect && Kind != RK_IntegerMinMax &&
312 Kind != RK_FloatMinMax && hasMultipleUsesOf(Cur, VisitedInsts, 1))
316 if (IsAPhi && Cur != Phi && !areAllUsesIn(Cur, VisitedInsts))
319 if (Kind == RK_IntegerMinMax &&
320 (isa<ICmpInst>(Cur) || isa<SelectInst>(Cur)))
321 ++NumCmpSelectPatternInst;
322 if (Kind == RK_FloatMinMax && (isa<FCmpInst>(Cur) || isa<SelectInst>(Cur)))
323 ++NumCmpSelectPatternInst;
326 FoundReduxOp |= !IsAPhi && Cur != Start;
341 if (ExitInstruction == Cur)
348 if (ExitInstruction !=
nullptr || Cur == Phi)
357 ExitInstruction = Cur;
364 InstDesc IgnoredVal(
false,
nullptr);
365 if (VisitedInsts.
insert(UI).second) {
366 if (isa<PHINode>(UI))
370 }
else if (!isa<PHINode>(UI) &&
371 ((!isa<FCmpInst>(UI) && !isa<ICmpInst>(UI) &&
372 !isa<SelectInst>(UI)) ||
373 (!isConditionalRdxPattern(Kind, UI).isRecurrence() &&
374 !isMinMaxSelectCmpPattern(UI, IgnoredVal).isRecurrence())))
379 FoundStartPHI =
true;
387 if ((Kind == RK_IntegerMinMax || Kind == RK_FloatMinMax) &&
388 NumCmpSelectPatternInst != 2)
391 if (!FoundStartPHI || !FoundReduxOp || !ExitInstruction)
420 std::tie(ComputedType, IsSigned) =
422 if (ComputedType != RecurrenceType)
457 assert((isa<ICmpInst>(I) || isa<FCmpInst>(I) || isa<SelectInst>(I)) &&
458 "Expect a select instruction");
464 if ((Cmp = dyn_cast<ICmpInst>(I)) || (Cmp = dyn_cast<FCmpInst>(I))) {
471 if (!(Select = dyn_cast<SelectInst>(I)))
473 if (!(Cmp = dyn_cast<ICmpInst>(I->
getOperand(0))) &&
484 return InstDesc(Select, MRK_UIntMin);
486 return InstDesc(Select, MRK_UIntMax);
488 return InstDesc(Select, MRK_SIntMax);
490 return InstDesc(Select, MRK_SIntMin);
492 return InstDesc(Select, MRK_FloatMin);
494 return InstDesc(Select, MRK_FloatMax);
496 return InstDesc(Select, MRK_FloatMin);
498 return InstDesc(Select, MRK_FloatMax);
528 if ((isa<PHINode>(*TrueVal) && isa<PHINode>(*FalseVal)) ||
529 (!isa<PHINode>(*TrueVal) && !isa<PHINode>(*FalseVal)))
534 : dyn_cast<Instruction>(TrueVal);
542 return InstDesc(Kind == RK_FloatAdd, SI);
545 return InstDesc(Kind == RK_FloatMult, SI);
552 InstDesc &Prev,
bool HasFunNoNaNAttr) {
555 if (!UAI && FP && !I->
isFast())
561 case Instruction::PHI:
563 case Instruction::Sub:
565 return InstDesc(Kind == RK_IntegerAdd, I);
566 case Instruction::Mul:
567 return InstDesc(Kind == RK_IntegerMult, I);
568 case Instruction::And:
569 return InstDesc(Kind == RK_IntegerAnd, I);
570 case Instruction::Or:
571 return InstDesc(Kind == RK_IntegerOr, I);
572 case Instruction::Xor:
573 return InstDesc(Kind == RK_IntegerXor, I);
574 case Instruction::FMul:
575 return InstDesc(Kind == RK_FloatMult, I, UAI);
576 case Instruction::FSub:
577 case Instruction::FAdd:
578 return InstDesc(Kind == RK_FloatAdd, I, UAI);
580 if (Kind == RK_FloatAdd || Kind == RK_FloatMult)
581 return isConditionalRdxPattern(Kind, I);
583 case Instruction::FCmp:
584 case Instruction::ICmp:
585 if (Kind != RK_IntegerMinMax &&
586 (!HasFunNoNaNAttr || Kind != RK_FloatMinMax))
588 return isMinMaxSelectCmpPattern(I, Prev);
594 unsigned MaxNumUses) {
595 unsigned NumUses = 0;
598 if (Insts.
count(dyn_cast<Instruction>(*
Use)))
600 if (NumUses > MaxNumUses)
613 bool HasFunNoNaNAttr =
616 if (AddReductionVar(Phi, RK_IntegerAdd, TheLoop, HasFunNoNaNAttr, RedDes, DB,
618 LLVM_DEBUG(
dbgs() <<
"Found an ADD reduction PHI." << *Phi <<
"\n");
621 if (AddReductionVar(Phi, RK_IntegerMult, TheLoop, HasFunNoNaNAttr, RedDes, DB,
623 LLVM_DEBUG(
dbgs() <<
"Found a MUL reduction PHI." << *Phi <<
"\n");
626 if (AddReductionVar(Phi, RK_IntegerOr, TheLoop, HasFunNoNaNAttr, RedDes, DB,
628 LLVM_DEBUG(
dbgs() <<
"Found an OR reduction PHI." << *Phi <<
"\n");
631 if (AddReductionVar(Phi, RK_IntegerAnd, TheLoop, HasFunNoNaNAttr, RedDes, DB,
633 LLVM_DEBUG(
dbgs() <<
"Found an AND reduction PHI." << *Phi <<
"\n");
636 if (AddReductionVar(Phi, RK_IntegerXor, TheLoop, HasFunNoNaNAttr, RedDes, DB,
638 LLVM_DEBUG(
dbgs() <<
"Found a XOR reduction PHI." << *Phi <<
"\n");
641 if (AddReductionVar(Phi, RK_IntegerMinMax, TheLoop, HasFunNoNaNAttr, RedDes,
643 LLVM_DEBUG(
dbgs() <<
"Found a MINMAX reduction PHI." << *Phi <<
"\n");
646 if (AddReductionVar(Phi, RK_FloatMult, TheLoop, HasFunNoNaNAttr, RedDes, DB,
648 LLVM_DEBUG(
dbgs() <<
"Found an FMult reduction PHI." << *Phi <<
"\n");
651 if (AddReductionVar(Phi, RK_FloatAdd, TheLoop, HasFunNoNaNAttr, RedDes, DB,
653 LLVM_DEBUG(
dbgs() <<
"Found an FAdd reduction PHI." << *Phi <<
"\n");
656 if (AddReductionVar(Phi, RK_FloatMinMax, TheLoop, HasFunNoNaNAttr, RedDes, DB,
658 LLVM_DEBUG(
dbgs() <<
"Found an float MINMAX reduction PHI." << *Phi
679 if (!Preheader || !Latch)
690 if (!Previous || !TheLoop->
contains(Previous) || isa<PHINode>(Previous) ||
691 SinkAfter.
count(Previous))
701 if (
I->isCast() && (
I->getParent() == Phi->
getParent()) &&
I->hasOneUse() &&
704 SinkAfter[
I] = Previous;
710 if (
auto *
I = dyn_cast<Instruction>(U)) {
751 return Instruction::Mul;
753 return Instruction::Or;
755 return Instruction::And;
757 return Instruction::Xor;
759 return Instruction::FMul;
761 return Instruction::FAdd;
762 case RK_IntegerMinMax:
763 return Instruction::ICmp;
765 return Instruction::FCmp;
774 : StartValue(Start), IK(K), Step(Step), InductionBinOp(BOp) {
775 assert(IK != IK_NoInduction &&
"Not an induction");
779 assert(StartValue &&
"StartValue is null");
780 assert((IK != IK_PtrInduction || StartValue->getType()->isPointerTy()) &&
781 "StartValue is not a pointer for pointer induction");
782 assert((IK != IK_IntInduction || StartValue->getType()->isIntegerTy()) &&
783 "StartValue is not an integer for integer induction");
786 assert((!getConstIntStepValue() || !getConstIntStepValue()->
isZero()) &&
787 "Step value is zero");
789 assert((IK != IK_PtrInduction || getConstIntStepValue()) &&
790 "Step value should be constant for pointer induction");
792 "StepValue is not an integer");
795 "StepValue is not FP for FpInduction");
796 assert((IK != IK_FpInduction ||
798 (InductionBinOp->getOpcode() == Instruction::FAdd ||
799 InductionBinOp->getOpcode() == Instruction::FSub))) &&
800 "Binary opcode should be specified for FP induction");
803 for (
auto &Inst : *Casts) {
804 RedundantCasts.push_back(Inst);
817 if (isa<SCEVConstant>(Step))
836 Value *BEValue =
nullptr, *StartValue =
nullptr;
842 "Unexpected Phi node in the loop");
851 Value *Addend =
nullptr;
852 if (BOp->
getOpcode() == Instruction::FAdd) {
857 }
else if (BOp->
getOpcode() == Instruction::FSub)
865 if (
auto *
I = dyn_cast<Instruction>(Addend))
912 assert(CastInsts.
empty() &&
"CastInsts is expected to be empty.");
913 auto *PN = cast<PHINode>(PhiScev->
getValue());
914 assert(PSE.
getSCEV(PN) == AR &&
"Unexpected phi node SCEV expression");
925 auto getDef = [&](
const Value *Val) ->
Value * {
932 if (L->isLoopInvariant(Op0))
934 else if (L->isLoopInvariant(Op1))
944 Value *Val = PN->getIncomingValueForBlock(Latch);
952 bool InCastSequence =
false;
957 if (!Inst || !L->contains(Inst)) {
962 InCastSequence =
true;
963 if (InCastSequence) {
966 if (!CastInsts.
empty())
967 if (!Inst->hasOneUse())
977 return InCastSequence;
994 return isFPInductionPHI(Phi, TheLoop, PSE.
getSE(),
D);
1015 if (PhiScev != AR && SymbolicPhi) {
1018 return isInductionPHI(Phi, TheLoop, PSE.
getSE(),
D, AR, &Casts);
1021 return isInductionPHI(Phi, TheLoop, PSE.
getSE(),
D, AR);
1034 const SCEV *PhiScev = Expr ? Expr : SE->
getSCEV(Phi);
1042 if (AR->
getLoop() != TheLoop) {
1046 dbgs() <<
"LV: PHI is a recurrence with respect to an outer loop.\n");
1074 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.
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.
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.
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.
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.
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.
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.
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.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
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.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
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.
uint64_t getTypeSizeInBits(Type *Ty) const
Size examples:
uint64_t getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
static bool isZero(Value *V, const DataLayout &DL, DominatorTree *DT, AssumptionCache *AC)
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
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.
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.
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.