Changeset View
Changeset View
Standalone View
Standalone View
include/llvm/Transforms/Utils/LoopUtils.h
Show All 15 Lines | |||||
#include "llvm/ADT/DenseMap.h" | #include "llvm/ADT/DenseMap.h" | ||||
#include "llvm/ADT/Optional.h" | #include "llvm/ADT/Optional.h" | ||||
#include "llvm/ADT/SetVector.h" | #include "llvm/ADT/SetVector.h" | ||||
#include "llvm/ADT/SmallPtrSet.h" | #include "llvm/ADT/SmallPtrSet.h" | ||||
#include "llvm/ADT/SmallVector.h" | #include "llvm/ADT/SmallVector.h" | ||||
#include "llvm/ADT/StringRef.h" | #include "llvm/ADT/StringRef.h" | ||||
#include "llvm/Analysis/AliasAnalysis.h" | #include "llvm/Analysis/AliasAnalysis.h" | ||||
#include "llvm/Analysis/DemandedBits.h" | |||||
#include "llvm/Analysis/EHPersonalities.h" | #include "llvm/Analysis/EHPersonalities.h" | ||||
#include "llvm/Analysis/TargetTransformInfo.h" | #include "llvm/Analysis/TargetTransformInfo.h" | ||||
#include "llvm/IR/Dominators.h" | #include "llvm/IR/Dominators.h" | ||||
#include "llvm/IR/IRBuilder.h" | #include "llvm/IR/IRBuilder.h" | ||||
#include "llvm/IR/InstrTypes.h" | #include "llvm/IR/InstrTypes.h" | ||||
#include "llvm/IR/Operator.h" | #include "llvm/IR/Operator.h" | ||||
#include "llvm/IR/ValueHandle.h" | #include "llvm/IR/ValueHandle.h" | ||||
#include "llvm/Support/Casting.h" | #include "llvm/Support/Casting.h" | ||||
▲ Show 20 Lines • Show All 135 Lines • ▼ Show 20 Lines | public: | ||||
/// RecurrenceKind. | /// RecurrenceKind. | ||||
static unsigned getRecurrenceBinOp(RecurrenceKind Kind); | static unsigned getRecurrenceBinOp(RecurrenceKind Kind); | ||||
/// Returns a Min/Max operation corresponding to MinMaxRecurrenceKind. | /// Returns a Min/Max operation corresponding to MinMaxRecurrenceKind. | ||||
static Value *createMinMaxOp(IRBuilder<> &Builder, MinMaxRecurrenceKind RK, | static Value *createMinMaxOp(IRBuilder<> &Builder, MinMaxRecurrenceKind RK, | ||||
Value *Left, Value *Right); | Value *Left, Value *Right); | ||||
/// Returns true if Phi is a reduction of type Kind and adds it to the | /// Returns true if Phi is a reduction of type Kind and adds it to the | ||||
/// RecurrenceDescriptor. | /// RecurrenceDescriptor. If either \p DB is non-null or \p AC and \p DT are | ||||
/// non-null, the minimal bit width needed to compute the reduction will be | |||||
/// computed. | |||||
static bool AddReductionVar(PHINode *Phi, RecurrenceKind Kind, Loop *TheLoop, | static bool AddReductionVar(PHINode *Phi, RecurrenceKind Kind, Loop *TheLoop, | ||||
bool HasFunNoNaNAttr, | bool HasFunNoNaNAttr, | ||||
RecurrenceDescriptor &RedDes); | RecurrenceDescriptor &RedDes, | ||||
DemandedBits *DB = nullptr, | |||||
/// Returns true if Phi is a reduction in TheLoop. The RecurrenceDescriptor is | AssumptionCache *AC = nullptr, | ||||
/// returned in RedDes. | DominatorTree *DT = nullptr); | ||||
/// Returns true if Phi is a reduction in TheLoop. The RecurrenceDescriptor | |||||
/// is returned in RedDes. If either \p DB is non-null or \p AC and \p DT are | |||||
/// non-null, the minimal bit width needed to compute the reduction will be | |||||
/// computed. | |||||
static bool isReductionPHI(PHINode *Phi, Loop *TheLoop, | static bool isReductionPHI(PHINode *Phi, Loop *TheLoop, | ||||
RecurrenceDescriptor &RedDes); | RecurrenceDescriptor &RedDes, | ||||
DemandedBits *DB = nullptr, | |||||
AssumptionCache *AC = nullptr, | |||||
DominatorTree *DT = nullptr); | |||||
/// Returns true if Phi is a first-order recurrence. A first-order recurrence | /// 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 | /// is a non-reduction recurrence relation in which the value of the | ||||
/// recurrence in the current loop iteration equals a value defined in the | /// recurrence in the current loop iteration equals a value defined in the | ||||
/// previous iteration. \p SinkAfter includes pairs of instructions where the | /// previous iteration. \p SinkAfter includes pairs of instructions where the | ||||
/// first will be rescheduled to appear after the second if/when the loop is | /// 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 | /// vectorized. It may be augmented with additional pairs if needed in order | ||||
/// to handle Phi as a first-order recurrence. | /// to handle Phi as a first-order recurrence. | ||||
Show All 21 Lines | public: | ||||
static bool isIntegerRecurrenceKind(RecurrenceKind Kind); | static bool isIntegerRecurrenceKind(RecurrenceKind Kind); | ||||
/// Returns true if the recurrence kind is a floating point kind. | /// Returns true if the recurrence kind is a floating point kind. | ||||
static bool isFloatingPointRecurrenceKind(RecurrenceKind Kind); | static bool isFloatingPointRecurrenceKind(RecurrenceKind Kind); | ||||
/// Returns true if the recurrence kind is an arithmetic kind. | /// Returns true if the recurrence kind is an arithmetic kind. | ||||
static bool isArithmeticRecurrenceKind(RecurrenceKind Kind); | static bool isArithmeticRecurrenceKind(RecurrenceKind Kind); | ||||
/// Determines if Phi may have been type-promoted. If Phi has a single user | |||||
/// that ANDs the Phi with a type mask, return the user. RT is updated to | |||||
/// account for the narrower bit width represented by the mask, and the AND | |||||
/// instruction is added to CI. | |||||
static Instruction *lookThroughAnd(PHINode *Phi, Type *&RT, | |||||
SmallPtrSetImpl<Instruction *> &Visited, | |||||
SmallPtrSetImpl<Instruction *> &CI); | |||||
/// Returns true if all the source operands of a recurrence are either | |||||
/// SExtInsts or ZExtInsts. This function is intended to be used with | |||||
/// lookThroughAnd to determine if the recurrence has been type-promoted. The | |||||
/// source operands are added to CI, and IsSigned is updated to indicate if | |||||
/// all source operands are SExtInsts. | |||||
static bool getSourceExtensionKind(Instruction *Start, Instruction *Exit, | |||||
Type *RT, bool &IsSigned, | |||||
SmallPtrSetImpl<Instruction *> &Visited, | |||||
SmallPtrSetImpl<Instruction *> &CI); | |||||
/// Returns the type of the recurrence. This type can be narrower than the | /// 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. | /// actual type of the Phi if the recurrence has been type-promoted. | ||||
Type *getRecurrenceType() { return RecurrenceType; } | Type *getRecurrenceType() { return RecurrenceType; } | ||||
/// Returns a reference to the instructions used for type-promoting the | /// Returns a reference to the instructions used for type-promoting the | ||||
/// recurrence. | /// recurrence. | ||||
SmallPtrSet<Instruction *, 8> &getCastInsts() { return CastInsts; } | SmallPtrSet<Instruction *, 8> &getCastInsts() { return CastInsts; } | ||||
▲ Show 20 Lines • Show All 329 Lines • Show Last 20 Lines |