|
LLVM
4.0.0
|
A struct for saving information about induction variables. More...
#include <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 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... | |
A struct for saving information about induction variables.
Definition at line 261 of file LoopUtils.h.
This enum represents the kinds of inductions that we support.
Definition at line 264 of file LoopUtils.h.
|
inline |
Default constructor - creates an invalid induction.
Definition at line 273 of file LoopUtils.h.
Referenced by isFPInductionPHI(), and isInductionPHI().
| 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 688 of file LoopUtils.cpp.
References getConstIntStepValue(), llvm::ConstantInt::getSExtValue(), llvm::ConstantInt::isMinusOne(), and llvm::ConstantInt::isOne().
| ConstantInt * InductionDescriptor::getConstIntStepValue | ( | ) | const |
Definition at line 695 of file LoopUtils.cpp.
References llvm::dyn_cast().
Referenced by getConsecutiveDirection(), and transform().
|
inline |
Returns binary opcode of the induction operator.
Definition at line 340 of file LoopUtils.h.
References llvm::BinaryOperator::getOpcode().
|
inline |
Definition at line 293 of file LoopUtils.h.
|
inline |
Definition at line 292 of file LoopUtils.h.
Definition at line 294 of file LoopUtils.h.
|
inline |
Returns induction operator that does not have "fast-math" property and requires FP unsafe mode.
Definition at line 332 of file LoopUtils.h.
References 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 325 of file LoopUtils.h.
Referenced by getUnsafeAlgebraInst().
|
static |
Returns true if Phi is a floating point induction in the loop L.
If Phi is an induction, the induction descriptor D will contain the data describing this induction.
Definition at line 769 of file LoopUtils.cpp.
References assert(), llvm::LoopBase< N, M >::contains(), llvm::dyn_cast(), llvm::LoopBase< N, M >::getHeader(), llvm::PHINode::getIncomingBlock(), llvm::PHINode::getIncomingValue(), llvm::PHINode::getNumIncomingValues(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::Instruction::getParent(), llvm::Value::getType(), llvm::ScalarEvolution::getUnknown(), I, IK_FpInduction, InductionDescriptor(), and llvm::Type::isFloatingPointTy().
Referenced by isInductionPHI().
|
static |
Returns true if Phi is an induction in the loop L.
If Phi is an induction, the induction descriptor D will contain the data describing this induction. If by some other means the caller has a better SCEV expression for Phi than the one returned by the ScalarEvolution analysis, it can be passed through Expr.
Definition at line 854 of file LoopUtils.cpp.
References assert(), llvm::dbgs(), DEBUG, llvm::dyn_cast(), llvm::ScalarEvolution::getConstant(), llvm::Module::getDataLayout(), llvm::PHINode::getIncomingValueForBlock(), llvm::SCEVAddRecExpr::getLoop(), llvm::LoopBase< N, M >::getLoopPreheader(), llvm::Instruction::getModule(), llvm::Type::getPointerElementType(), llvm::ScalarEvolution::getSCEV(), llvm::ConstantInt::getSExtValue(), llvm::SCEVAddRecExpr::getStepRecurrence(), llvm::ConstantInt::getType(), llvm::Value::getType(), llvm::DataLayout::getTypeAllocSize(), llvm::SCEVConstant::getValue(), IK_IntInduction, IK_PtrInduction, InductionDescriptor(), llvm::Type::isIntegerTy(), llvm::ScalarEvolution::isLoopInvariant(), llvm::Type::isPointerTy(), and llvm::Type::isSized().
Referenced by isInductionPHI().
|
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 822 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 |
Compute the transformed value of Index at offset StartValue using step StepValue.
For integer induction, returns StartValue + Index * StepValue. For pointer induction, returns StartValue[Index * StepValue]. FIXME: The newly created binary instructions should contain nsw/nuw flags, which can be found from the original scalar operations.
Definition at line 701 of file LoopUtils.cpp.
References assert(), llvm::IRBuilder< T, Inserter >::CreateAdd(), llvm::IRBuilder< T, Inserter >::CreateBinOp(), llvm::IRBuilder< T, Inserter >::CreateFMul(), llvm::IRBuilder< T, Inserter >::CreateGEP(), llvm::IRBuilder< T, Inserter >::CreateSub(), llvm::SCEVExpander::expandCodeFor(), fuzzer::Flags, llvm::ScalarEvolution::getAddExpr(), getConstIntStepValue(), llvm::IRBuilderBase::GetInsertPoint(), llvm::ScalarEvolution::getMulExpr(), llvm::BinaryOperator::getOpcode(), llvm::ScalarEvolution::getSCEV(), llvm::SCEV::getType(), llvm::Value::getType(), IK_FpInduction, IK_IntInduction, IK_NoInduction, IK_PtrInduction, llvm::Type::isFloatingPointTy(), llvm::ConstantInt::isMinusOne(), llvm_unreachable, and llvm::FastMathFlags::setUnsafeAlgebra().
1.8.6