|
LLVM
3.7.0
|
The RecurrenceDescriptor is used to identify recurrences variables in a loop. More...
#include <LoopUtils.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 () | |
| RecurrenceDescriptor (Value *Start, Instruction *Exit, RecurrenceKind K, MinMaxRecurrenceKind MK) | |
| RecurrenceKind | getRecurrenceKind () |
| MinMaxRecurrenceKind | getMinMaxRecurrenceKind () |
| TrackingVH< Value > | getRecurrenceStartValue () |
| Instruction * | getLoopExitInstr () |
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) |
| Returns true if instuction 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 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 Value * | createMinMaxOp (IRBuilder<> &Builder, MinMaxRecurrenceKind RK, Value *Left, Value *Right) |
| Returns a Min/Max operation corresponding to MinMaxRecurrenceKind. More... | |
| 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. More... | |
| static bool | isReductionPHI (PHINode *Phi, Loop *TheLoop, RecurrenceDescriptor &RedDes) |
| Returns true if Phi is a reduction in TheLoop. 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 58 of file LoopUtils.h.
| Enumerator | |
|---|---|
| MRK_Invalid | |
| MRK_UIntMin | |
| MRK_UIntMax | |
| MRK_SIntMin | |
| MRK_SIntMax | |
| MRK_FloatMin | |
| MRK_FloatMax | |
Definition at line 76 of file LoopUtils.h.
This enum represents the kinds of recurrences that we support.
Definition at line 62 of file LoopUtils.h.
|
inline |
Definition at line 86 of file LoopUtils.h.
|
inline |
Definition at line 90 of file LoopUtils.h.
|
static |
Returns true if Phi is a reduction of type Kind and adds it to the RecurrenceDescriptor.
Definition at line 37 of file LoopUtils.cpp.
References llvm::SmallVectorImpl< T >::append(), llvm::SmallVectorTemplateCommon< T >::back(), llvm::SmallVectorTemplateCommon< T >::begin(), llvm::LoopBase< N, M >::contains(), llvm::SmallPtrSetImpl< PtrType >::count(), llvm::SmallVectorBase::empty(), llvm::SmallVectorTemplateCommon< T >::end(), llvm::LoopBase< N, M >::getHeader(), llvm::PHINode::getIncomingValueForBlock(), llvm::LoopBase< N, M >::getLoopPreheader(), llvm::RecurrenceDescriptor::InstDesc::getMinMaxKind(), llvm::PHINode::getNumIncomingValues(), llvm::User::getOperand(), llvm::Instruction::getParent(), llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::Instruction::isCommutative(), llvm::RecurrenceDescriptor::InstDesc::isRecurrence(), llvm::User::op_begin(), llvm::User::op_end(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::pop_back(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), llvm::Value::use_empty(), and llvm::Value::users().
|
static |
Returns true if all uses of the instruction I is within the Set.
Definition at line 29 of file LoopUtils.cpp.
References llvm::SmallPtrSetImpl< PtrType >::count(), llvm::User::op_begin(), and llvm::User::op_end().
|
static |
Returns a Min/Max operation corresponding to MinMaxRecurrenceKind.
Definition at line 418 of file LoopUtils.cpp.
References llvm::IRBuilder< preserveNames, T, Inserter >::CreateFCmp(), llvm::IRBuilder< preserveNames, T, Inserter >::CreateICmp(), llvm::IRBuilder< preserveNames, T, Inserter >::CreateSelect(), llvm::CmpInst::FCMP_OGT, llvm::CmpInst::FCMP_OLT, llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_SLT, llvm::CmpInst::ICMP_UGT, llvm::CmpInst::ICMP_ULT, llvm_unreachable, P, and llvm::MCID::Select.
|
inline |
Definition at line 168 of file LoopUtils.h.
|
inline |
Definition at line 164 of file LoopUtils.h.
|
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 393 of file LoopUtils.cpp.
References llvm::APIntOps::And(), llvm_unreachable, llvm::APIntOps::Or(), and llvm::APIntOps::Xor().
|
static |
Returns identity corresponding to the RecurrenceKind.
This function returns the identity element (or neutral element) for the operation K.
Definition at line 367 of file LoopUtils.cpp.
References llvm::ConstantInt::get(), llvm::ConstantFP::get(), and llvm_unreachable.
|
inline |
Definition at line 162 of file LoopUtils.h.
|
inline |
Definition at line 166 of file LoopUtils.h.
|
static |
Returns true if instuction I has multiple uses in Insts.
Definition at line 301 of file LoopUtils.cpp.
References llvm::SmallPtrSetImpl< PtrType >::count(), llvm::User::op_begin(), and llvm::User::op_end().
|
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 214 of file LoopUtils.cpp.
References 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().
|
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 263 of file LoopUtils.cpp.
References llvm::APIntOps::And(), llvm::RecurrenceDescriptor::InstDesc::getMinMaxKind(), llvm::Instruction::getOpcode(), llvm::Value::getType(), llvm::Instruction::hasUnsafeAlgebra(), llvm::Type::isFloatingPointTy(), llvm::APIntOps::Or(), llvm::TargetOpcode::PHI, llvm::MCID::Select, and llvm::APIntOps::Xor().
|
static |
Returns true if Phi is a reduction in TheLoop.
The RecurrenceDescriptor is returned in RedDes.
Definition at line 314 of file LoopUtils.cpp.
References llvm::dbgs(), DEBUG, F(), llvm::Function::getFnAttribute(), llvm::LoopBase< N, M >::getHeader(), llvm::BasicBlock::getParent(), llvm::Attribute::getValueAsString(), and llvm::Function::hasFnAttribute().
1.8.6