LLVM  5.0.0
Public Types | Public Member Functions | Static Public Member Functions | List of all members
llvm::InductionDescriptor Class Reference

A struct for saving information about induction variables. More...

#include "llvm/Transforms/Utils/LoopUtils.h"

Public Types

enum  InductionKind { IK_NoInduction, IK_IntInduction, IK_PtrInduction, IK_FpInduction }
 This enum represents the kinds of inductions that we support. More...
 

Public Member Functions

 InductionDescriptor ()=default
 Default constructor - creates an invalid induction. More...
 
int getConsecutiveDirection () const
 Get the consecutive direction. More...
 
Value * transform (IRBuilder<> &B, Value *Index, ScalarEvolution *SE, const DataLayout &DL) const
 Compute the transformed value of Index at offset StartValue using step StepValue. More...
 
Value * getStartValue () const
 
InductionKind getKind () const
 
const SCEV * getStep () const
 
ConstantInt * getConstIntStepValue () const
 
bool hasUnsafeAlgebra ()
 Returns true if the induction type is FP and the binary operator does not have the "fast-math" property. More...
 
Instruction * getUnsafeAlgebraInst ()
 Returns induction operator that does not have "fast-math" property and requires FP unsafe mode. More...
 
Instruction::BinaryOps getInductionOpcode () const
 Returns binary opcode of the induction operator. More...
 

Static Public Member Functions

static bool isInductionPHI (PHINode *Phi, const Loop *L, ScalarEvolution *SE, InductionDescriptor &D, const SCEV *Expr=nullptr)
 Returns true if Phi is an induction in the loop L. More...
 
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. More...
 
static bool isInductionPHI (PHINode *Phi, const Loop *L, PredicatedScalarEvolution &PSE, InductionDescriptor &D, bool Assume=false)
 Returns true if Phi is a loop L induction, in the context associated with the run-time predicate of PSE. More...
 

Detailed Description

A struct for saving information about induction variables.

Definition at line 270 of file LoopUtils.h.

Member Enumeration Documentation

This enum represents the kinds of inductions that we support.

Enumerator
IK_NoInduction 

Not an induction variable.

IK_IntInduction 

Integer induction variable. Step = C.

IK_PtrInduction 

Pointer induction var. Step = C / sizeof(elem).

IK_FpInduction 

Floating point induction variable.

Definition at line 273 of file LoopUtils.h.

Constructor & Destructor Documentation

llvm::InductionDescriptor::InductionDescriptor ( )
default

Default constructor - creates an invalid induction.

Referenced by isFPInductionPHI(), and isInductionPHI().

Member Function Documentation

int InductionDescriptor::getConsecutiveDirection ( ) const

Get the consecutive direction.

Returns: 0 - unknown or non-consecutive. 1 - consecutive and increasing. -1 - consecutive and decreasing.

Definition at line 709 of file LoopUtils.cpp.

References getConstIntStepValue(), llvm::ConstantInt::getSExtValue(), llvm::ConstantInt::isMinusOne(), and llvm::ConstantInt::isOne().

ConstantInt * InductionDescriptor::getConstIntStepValue ( ) const

Definition at line 716 of file LoopUtils.cpp.

References llvm::dyn_cast().

Referenced by getConsecutiveDirection(), and transform().

Instruction::BinaryOps llvm::InductionDescriptor::getInductionOpcode ( ) const
inline

Returns binary opcode of the induction operator.

Definition at line 347 of file LoopUtils.h.

References llvm::BinaryOperator::getOpcode().

InductionKind llvm::InductionDescriptor::getKind ( ) const
inline

Definition at line 300 of file LoopUtils.h.

Value* llvm::InductionDescriptor::getStartValue ( ) const
inline

Definition at line 299 of file LoopUtils.h.

const SCEV* llvm::InductionDescriptor::getStep ( ) const
inline

Definition at line 301 of file LoopUtils.h.

Instruction* llvm::InductionDescriptor::getUnsafeAlgebraInst ( )
inline

Returns induction operator that does not have "fast-math" property and requires FP unsafe mode.

Definition at line 339 of file LoopUtils.h.

References hasUnsafeAlgebra().

bool llvm::InductionDescriptor::hasUnsafeAlgebra ( )
inline

Returns true if the induction type is FP and the binary operator does not have the "fast-math" property.

Such operation requires a relaxed FP mode.

Definition at line 332 of file LoopUtils.h.

Referenced by getUnsafeAlgebraInst().

bool InductionDescriptor::isFPInductionPHI ( PHINode *  Phi,
const Loop *  L,
ScalarEvolution *  SE,
InductionDescriptor &  D 
)
static
bool InductionDescriptor::isInductionPHI ( PHINode *  Phi,
const Loop *  L,
ScalarEvolution *  SE,
InductionDescriptor &  D,
const SCEV *  Expr = nullptr 
)
static
bool InductionDescriptor::isInductionPHI ( PHINode *  Phi,
const Loop *  L,
PredicatedScalarEvolution &  PSE,
InductionDescriptor &  D,
bool  Assume = false 
)
static

Returns true if Phi is a loop L induction, in the context associated with the run-time predicate of PSE.

If Assume is true, this can add further SCEV predicates to PSE in order to prove that Phi is an induction. If Phi is an induction, D will contain the data describing this induction.

Definition at line 843 of file LoopUtils.cpp.

References D, llvm::dbgs(), DEBUG, llvm::dyn_cast(), llvm::PredicatedScalarEvolution::getAsAddRec(), llvm::PredicatedScalarEvolution::getSCEV(), llvm::PredicatedScalarEvolution::getSE(), llvm::Value::getType(), llvm::Type::isDoubleTy(), llvm::Type::isFloatingPointTy(), llvm::Type::isFloatTy(), isFPInductionPHI(), llvm::Type::isHalfTy(), isInductionPHI(), llvm::Type::isIntegerTy(), and llvm::Type::isPointerTy().

Value * InductionDescriptor::transform ( IRBuilder<> &  B,
Value *  Index,
ScalarEvolution *  SE,
const DataLayout &  DL 
) const

The documentation for this class was generated from the following files: