|
LLVM
10.0.0
|
The RecurrenceDescriptor is used to identify recurrences variables in a loop. More...
#include "llvm/Analysis/IVDescriptors.h"
Classes | |
| class | InstDesc |
| This POD struct holds information about a potential recurrence operation. More... | |
Public Types | |
| enum | RecurrenceKind { RK_NoRecurrence, RK_IntegerAdd, RK_IntegerMult, RK_IntegerOr, RK_IntegerAnd, RK_IntegerXor, RK_IntegerMinMax, RK_FloatAdd, RK_FloatMult, RK_FloatMinMax } |
| This enum represents the kinds of recurrences that we support. More... | |
| enum | MinMaxRecurrenceKind { MRK_Invalid, MRK_UIntMin, MRK_UIntMax, MRK_SIntMin, MRK_SIntMax, MRK_FloatMin, MRK_FloatMax } |
Public Member Functions | |
| RecurrenceDescriptor ()=default | |
| RecurrenceDescriptor (Value *Start, Instruction *Exit, RecurrenceKind K, FastMathFlags FMF, MinMaxRecurrenceKind MK, Instruction *UAI, Type *RT, bool Signed, SmallPtrSetImpl< Instruction *> &CI) | |
| RecurrenceKind | getRecurrenceKind () |
| MinMaxRecurrenceKind | getMinMaxRecurrenceKind () |
| FastMathFlags | getFastMathFlags () |
| TrackingVH< Value > | getRecurrenceStartValue () |
| Instruction * | getLoopExitInstr () |
| bool | hasUnsafeAlgebra () |
| Returns true if the recurrence has unsafe algebra which requires a relaxed floating-point model. More... | |
| Instruction * | getUnsafeAlgebraInst () |
| Returns first unsafe algebra instruction in the PHI node's use-chain. More... | |
| Type * | getRecurrenceType () |
| Returns the type of the recurrence. More... | |
| SmallPtrSet< Instruction *, 8 > & | getCastInsts () |
| Returns a reference to the instructions used for type-promoting the recurrence. More... | |
| bool | isSigned () |
| Returns true if all source operands of the recurrence are SExtInsts. More... | |
Static Public Member Functions | |
| 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'. More... | |
| static bool | hasMultipleUsesOf (Instruction *I, SmallPtrSetImpl< Instruction *> &Insts, unsigned MaxNumUses) |
| Returns true if instruction I has multiple uses in Insts. More... | |
| static bool | areAllUsesIn (Instruction *I, SmallPtrSetImpl< Instruction *> &Set) |
| Returns true if all uses of the instruction I is within the Set. More... | |
| 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). More... | |
| 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. More... | |
| static Constant * | getRecurrenceIdentity (RecurrenceKind K, Type *Tp) |
| Returns identity corresponding to the RecurrenceKind. More... | |
| static unsigned | getRecurrenceBinOp (RecurrenceKind Kind) |
| Returns the opcode of binary operation corresponding to the RecurrenceKind. More... | |
| 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. More... | |
| 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. More... | |
| static bool | isFirstOrderRecurrence (PHINode *Phi, Loop *TheLoop, DenseMap< Instruction *, Instruction *> &SinkAfter, DominatorTree *DT) |
| Returns true if Phi is a first-order recurrence. More... | |
| static bool | isIntegerRecurrenceKind (RecurrenceKind Kind) |
| Returns true if the recurrence kind is an integer kind. More... | |
| static bool | isFloatingPointRecurrenceKind (RecurrenceKind Kind) |
| Returns true if the recurrence kind is a floating point kind. More... | |
| static bool | isArithmeticRecurrenceKind (RecurrenceKind Kind) |
| Returns true if the recurrence kind is an arithmetic kind. More... | |
The RecurrenceDescriptor is used to identify recurrences variables in a loop.
Reduction is a special case of recurrence that has uses of the recurrence variable outside the loop. The method isReductionPHI identifies reductions that are basic recurrences.
Basic recurrences are defined as the summation, product, OR, AND, XOR, min, or max of a set of terms. For example: for(i=0; i<n; i++) { total += array[i]; } is a summation of array elements. Basic recurrences are a special case of chains of recurrences (CR). See ScalarEvolution for CR references. This struct holds information about recurrence variables.
Definition at line 62 of file IVDescriptors.h.
| Enumerator | |
|---|---|
| MRK_Invalid | |
| MRK_UIntMin | |
| MRK_UIntMax | |
| MRK_SIntMin | |
| MRK_SIntMax | |
| MRK_FloatMin | |
| MRK_FloatMax | |
Definition at line 79 of file IVDescriptors.h.
This enum represents the kinds of recurrences that we support.
Definition at line 65 of file IVDescriptors.h.
|
default |
|
inline |
Definition at line 91 of file IVDescriptors.h.
|
static |
Returns true if Phi is a reduction of type Kind and adds it to the RecurrenceDescriptor.
If either DB is non-null or AC and DT are non-null, the minimal bit width needed to compute the reduction will be computed.
Definition at line 189 of file IVDescriptors.cpp.
References llvm::LoopBase< BlockT, LoopT >::getHeader(), llvm::PHINode::getIncomingValueForBlock(), llvm::LoopBase< BlockT, LoopT >::getLoopPreheader(), llvm::PHINode::getNumIncomingValues(), llvm::Instruction::getParent(), and llvm::Value::getType().
Referenced by llvm::RecurrenceDescriptor::InstDesc::getPatternInst().
|
static |
Returns true if all uses of the instruction I is within the Set.
Definition at line 42 of file IVDescriptors.cpp.
References llvm::SmallPtrSetImpl< PtrType >::count(), E, llvm::User::op_begin(), and llvm::User::op_end().
Referenced by llvm::RecurrenceDescriptor::InstDesc::getPatternInst().
|
inline |
Returns a reference to the instructions used for type-promoting the recurrence.
Definition at line 231 of file IVDescriptors.h.
Referenced by llvm::LoopVectorizationCostModel::collectValuesToIgnore().
|
inline |
Definition at line 203 of file IVDescriptors.h.
Referenced by llvm::createTargetReduction().
|
inline |
Definition at line 207 of file IVDescriptors.h.
Referenced by llvm::InnerLoopVectorizer::clearReductionWrapFlags(), and llvm::LoopVectorizationLegality::isUniform().
|
inline |
Definition at line 201 of file IVDescriptors.h.
Referenced by llvm::createTargetReduction().
|
static |
Returns the opcode of binary operation corresponding to the RecurrenceKind.
This function translates the recurrence kind to an LLVM binary operator.
Definition at line 773 of file IVDescriptors.cpp.
References llvm::MCID::Add, llvm::InductionDescriptor::InductionDescriptor(), and llvm_unreachable.
Referenced by llvm::InnerLoopVectorizer::fixReduction(), and llvm::RecurrenceDescriptor::InstDesc::getPatternInst().
|
static |
Returns identity corresponding to the RecurrenceKind.
This function returns the identity element (or neutral element) for the operation K.
Definition at line 747 of file IVDescriptors.cpp.
References llvm::ConstantInt::get(), llvm::ConstantFP::get(), and llvm_unreachable.
Referenced by llvm::InnerLoopVectorizer::fixReduction(), and llvm::RecurrenceDescriptor::InstDesc::getPatternInst().
|
inline |
Definition at line 199 of file IVDescriptors.h.
Referenced by llvm::InnerLoopVectorizer::clearReductionWrapFlags(), llvm::createTargetReduction(), and llvm::InnerLoopVectorizer::fixReduction().
|
inline |
Definition at line 205 of file IVDescriptors.h.
|
inline |
Returns the type of the recurrence.
This type can be narrower than the actual type of the Phi if the recurrence has been type-promoted.
Definition at line 227 of file IVDescriptors.h.
Referenced by llvm::LoopVectorizationCostModel::getSmallestAndWidestTypes().
|
inline |
Returns first unsafe algebra instruction in the PHI node's use-chain.
Definition at line 214 of file IVDescriptors.h.
References isArithmeticRecurrenceKind(), isFloatingPointRecurrenceKind(), and isIntegerRecurrenceKind().
Referenced by llvm::LoopVectorizationLegality::isUniform().
|
static |
Returns true if instruction I has multiple uses in Insts.
Definition at line 596 of file IVDescriptors.cpp.
References llvm::SmallPtrSetImpl< PtrType >::count(), E, llvm::User::op_begin(), and llvm::User::op_end().
Referenced by llvm::RecurrenceDescriptor::InstDesc::getPatternInst().
|
inline |
Returns true if the recurrence has unsafe algebra which requires a relaxed floating-point model.
Definition at line 211 of file IVDescriptors.h.
Referenced by llvm::LoopVectorizationLegality::isUniform().
|
static |
Returns true if the recurrence kind is an arithmetic kind.
Definition at line 69 of file IVDescriptors.cpp.
Referenced by getUnsafeAlgebraInst().
|
static |
Returns a struct describing if the instruction is a Select(FCmp(X, Y), (Z = X op PHINode), PHINode) instruction pattern.
Returns true if the select instruction has users in the compare-and-add reduction pattern below.
The select instruction argument is the last one in the sequence.
sum.1 = phi ... ... cmp = fcmp pred %0, CFP add = fadd %0, sum.1 sum.2 = select cmp, add, sum.1
Definition at line 518 of file IVDescriptors.cpp.
References llvm::dyn_cast(), llvm::SelectInst::getCondition(), llvm::SelectInst::getFalseValue(), llvm::SelectInst::getTrueValue(), llvm::Value::hasOneUse(), I, llvm::Instruction::isBinaryOp(), llvm::Instruction::isFast(), llvm::PatternMatch::m_FAdd(), llvm::PatternMatch::m_FMul(), llvm::PatternMatch::m_FSub(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), and SI.
Referenced by llvm::RecurrenceDescriptor::InstDesc::getPatternInst().
|
static |
Returns true if Phi is a first-order recurrence.
A first-order recurrence is a non-reduction recurrence relation in which the value of the recurrence in the current loop iteration equals a value defined in the previous iteration. SinkAfter includes pairs of instructions where the first will be rescheduled to appear after the second if/when the loop is vectorized. It may be augmented with additional pairs if needed in order to handle Phi as a first-order recurrence.
Definition at line 670 of file IVDescriptors.cpp.
References llvm::all_of(), llvm::LoopBase< BlockT, LoopT >::contains(), llvm::DenseMapBase< DenseMap< KeyT, ValueT, KeyInfoT, BucketT >, KeyT, ValueT, KeyInfoT, BucketT >::count(), llvm::DominatorTree::dominates(), llvm::dyn_cast(), llvm::DenseMapBase< DenseMap< KeyT, ValueT, KeyInfoT, BucketT >, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::DenseMapBase< DenseMap< KeyT, ValueT, KeyInfoT, BucketT >, KeyT, ValueT, KeyInfoT, BucketT >::find(), llvm::PHINode::getBasicBlockIndex(), llvm::LoopBase< BlockT, LoopT >::getHeader(), llvm::PHINode::getIncomingValueForBlock(), llvm::LoopBase< BlockT, LoopT >::getLoopLatch(), llvm::LoopBase< BlockT, LoopT >::getLoopPreheader(), llvm::PHINode::getNumIncomingValues(), llvm::Instruction::getParent(), llvm::BasicBlock::getTerminator(), llvm::Value::hasOneUse(), I, llvm::Instruction::mayHaveSideEffects(), llvm::Instruction::user_back(), and llvm::Value::uses().
Referenced by llvm::RecurrenceDescriptor::InstDesc::getPatternInst(), and llvm::LoopVectorizationLegality::isUniform().
|
static |
Returns true if the recurrence kind is a floating point kind.
Definition at line 65 of file IVDescriptors.cpp.
Referenced by getUnsafeAlgebraInst().
|
static |
Returns true if the recurrence kind is an integer kind.
Definition at line 50 of file IVDescriptors.cpp.
Referenced by getUnsafeAlgebraInst().
|
static |
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).
Returns true if the instruction is a Select(ICmp(X, Y), X, Y) instruction pattern corresponding to a min(X, Y) or max(X, Y).
Definition at line 460 of file IVDescriptors.cpp.
References assert(), llvm::dyn_cast(), llvm::RecurrenceDescriptor::InstDesc::getMinMaxKind(), llvm::User::getOperand(), llvm::Value::hasOneUse(), llvm::PatternMatch::m_OrdFMax(), llvm::PatternMatch::m_OrdFMin(), llvm::PatternMatch::m_SMax(), llvm::PatternMatch::m_SMin(), llvm::PatternMatch::m_UMax(), llvm::PatternMatch::m_UMin(), llvm::PatternMatch::m_UnordFMax(), llvm::PatternMatch::m_UnordFMin(), llvm::PatternMatch::m_Value(), llvm::MCID::Select, and llvm::Value::user_begin().
Referenced by llvm::RecurrenceDescriptor::InstDesc::getPatternInst().
|
static |
Returns a struct describing if the instruction 'I' can be a recurrence variable of type 'Kind'.
If the recurrence is a min/max pattern of select(icmp()) this function advances the instruction pointer 'I' from the compare instruction to the select instruction and stores this pointer in 'PatternLastInst' member of the returned struct.
Definition at line 556 of file IVDescriptors.cpp.
References llvm::MCID::Add, llvm::RecurrenceDescriptor::InstDesc::getMinMaxKind(), llvm::Instruction::getOpcode(), llvm::RecurrenceDescriptor::InstDesc::getUnsafeAlgebraInst(), llvm::Instruction::hasAllowReassoc(), LLVM_FALLTHROUGH, and llvm::MCID::Select.
Referenced by llvm::RecurrenceDescriptor::InstDesc::getPatternInst().
|
static |
Returns true if Phi is a reduction in TheLoop.
The RecurrenceDescriptor is returned in RedDes. If either DB is non-null or AC and DT are non-null, the minimal bit width needed to compute the reduction will be computed.
Definition at line 610 of file IVDescriptors.cpp.
References llvm::dbgs(), F(), llvm::Function::getFnAttribute(), llvm::LoopBase< BlockT, LoopT >::getHeader(), llvm::BasicBlock::getParent(), llvm::Attribute::getValueAsString(), and LLVM_DEBUG.
Referenced by findInnerReductionPhi(), llvm::RecurrenceDescriptor::InstDesc::getPatternInst(), and llvm::LoopVectorizationLegality::isUniform().
|
inline |
Returns true if all source operands of the recurrence are SExtInsts.
Definition at line 234 of file IVDescriptors.h.
References MRK_Invalid, and RK_NoRecurrence.
1.8.13