LLVM  3.7.0
Public Member Functions | Friends | List of all members
llvm::SCEVExpander Class Reference

This class uses information about analyze scalars to rewrite expressions in canonical form. More...

#include <ScalarEvolutionExpander.h>

Inheritance diagram for llvm::SCEVExpander:
[legend]
Collaboration diagram for llvm::SCEVExpander:
[legend]

Public Member Functions

 SCEVExpander (ScalarEvolution &se, const DataLayout &DL, const char *name)
 Construct a SCEVExpander in "canonical" mode. More...
 
void setDebugType (const char *s)
 
void clear ()
 Erase the contents of the InsertedExpressions map so that users trying to expand the same expression into multiple BasicBlocks or different places within the same BasicBlock can do so. More...
 
bool isHighCostExpansion (const SCEV *Expr, Loop *L)
 Return true for expressions that may incur non-trivial cost to evaluate at runtime. More...
 
PHINodegetOrInsertCanonicalInductionVariable (const Loop *L, Type *Ty)
 This method returns the canonical induction variable of the specified type for the specified loop (inserting one if there is none). More...
 
InstructiongetIVIncOperand (Instruction *IncV, Instruction *InsertPos, bool allowScale)
 Return the induction variable increment's IV operand. More...
 
bool hoistIVInc (Instruction *IncV, Instruction *InsertPos)
 Utility for hoisting an IV increment. More...
 
unsigned replaceCongruentIVs (Loop *L, const DominatorTree *DT, SmallVectorImpl< WeakVH > &DeadInsts, const TargetTransformInfo *TTI=nullptr)
 replace congruent phis with their most canonical representative. More...
 
ValueexpandCodeFor (const SCEV *SH, Type *Ty, Instruction *I)
 Insert code to directly compute the specified SCEV expression into the program. More...
 
void setIVIncInsertPos (const Loop *L, Instruction *Pos)
 Set the current IV increment loop and position. More...
 
void setPostInc (const PostIncLoopSet &L)
 Enable post-inc expansion for addrecs referring to the given loops. More...
 
void clearPostInc ()
 Disable all post-inc expansion. More...
 
void disableCanonicalMode ()
 Disable the behavior of expanding expressions in canonical form rather than in a more literal form. More...
 
void enableLSRMode ()
 
void clearInsertPoint ()
 Clear the current insertion point. More...
 
bool isInsertedInstruction (Instruction *I) const
 Return true if the specified instruction was inserted by the code rewriter. More...
 
void setChainedPhi (PHINode *PN)
 
- Public Member Functions inherited from llvm::SCEVVisitor< SCEVExpander, Value * >
Valuevisit (const SCEV *S)
 
ValuevisitCouldNotCompute (const SCEVCouldNotCompute *S)
 

Friends

struct SCEVVisitor< SCEVExpander, Value * >
 

Detailed Description

This class uses information about analyze scalars to rewrite expressions in canonical form.

Clients should create an instance of this class when rewriting is needed, and destroy it when finished to allow the release of the associated memory.

Definition at line 37 of file ScalarEvolutionExpander.h.

Constructor & Destructor Documentation

llvm::SCEVExpander::SCEVExpander ( ScalarEvolution se,
const DataLayout DL,
const char *  name 
)
inlineexplicit

Construct a SCEVExpander in "canonical" mode.

Definition at line 94 of file ScalarEvolutionExpander.h.

Member Function Documentation

void llvm::SCEVExpander::clear ( )
inline

Erase the contents of the InsertedExpressions map so that users trying to expand the same expression into multiple BasicBlocks or different places within the same BasicBlock can do so.

Definition at line 111 of file ScalarEvolutionExpander.h.

void llvm::SCEVExpander::clearInsertPoint ( )
inline

Clear the current insertion point.

This is useful if the instruction that had been serving as the insertion point may have been deleted.

Definition at line 184 of file ScalarEvolutionExpander.h.

References llvm::IRBuilderBase::ClearInsertionPoint().

void llvm::SCEVExpander::clearPostInc ( )
inline

Disable all post-inc expansion.

Definition at line 166 of file ScalarEvolutionExpander.h.

References llvm::SmallPtrSetImplBase::clear().

void llvm::SCEVExpander::disableCanonicalMode ( )
inline

Disable the behavior of expanding expressions in canonical form rather than in a more literal form.

Non-canonical mode is useful for late optimization passes.

Definition at line 177 of file ScalarEvolutionExpander.h.

void llvm::SCEVExpander::enableLSRMode ( )
inline

Definition at line 179 of file ScalarEvolutionExpander.h.

Value * SCEVExpander::expandCodeFor ( const SCEV SH,
Type Ty,
Instruction I 
)

Insert code to directly compute the specified SCEV expression into the program.

The inserted code is inserted into the specified block.

Definition at line 1588 of file ScalarEvolutionExpander.cpp.

References llvm::Instruction::getParent().

Referenced by llvm::LoopAccessInfo::addRuntimeCheck(), genLoopLimit(), and llvm::UnrollRuntimeLoopProlog().

Instruction * SCEVExpander::getIVIncOperand ( Instruction IncV,
Instruction InsertPos,
bool  allowScale 
)

Return the induction variable increment's IV operand.

getIVIncOperand returns an induction variable increment's induction variable operand.

If allowScale is set, any type of GEP is allowed as long as the nonIV operands dominate InsertPos.

If allowScale is not set, ensure that a GEP increment conforms to one of the simple patterns generated by getAddRecExprPHILiterally and expandAddtoGEP. If the pattern isn't recognized, return NULL.

Definition at line 863 of file ScalarEvolutionExpander.cpp.

References llvm::dyn_cast(), llvm::Type::getInt1PtrTy(), llvm::Type::getInt8PtrTy(), llvm::User::getNumOperands(), llvm::Instruction::getOpcode(), llvm::User::getOperand(), llvm::Value::getType(), I, llvm::User::op_begin(), and llvm::User::op_end().

PHINode * SCEVExpander::getOrInsertCanonicalInductionVariable ( const Loop L,
Type Ty 
)

This method returns the canonical induction variable of the specified type for the specified loop (inserting one if there is none).

getOrInsertCanonicalInductionVariable - This method returns the canonical induction variable of the specified type for the specified loop (inserting one if there is none).

A canonical induction variable starts at zero and steps by one on each iteration.

Definition at line 1669 of file ScalarEvolutionExpander.cpp.

References llvm::SCEV::FlagAnyWrap, llvm::LoopBase< N, M >::getHeader(), H, and llvm::Type::isIntegerTy().

bool SCEVExpander::hoistIVInc ( Instruction IncV,
Instruction InsertPos 
)

Utility for hoisting an IV increment.

hoistStep - Attempt to hoist a simple IV increment above InsertPos to make it available to other uses in this loop.

Recursively hoist any operands, until we reach a value that dominates InsertPos.

Definition at line 914 of file ScalarEvolutionExpander.cpp.

References llvm::Instruction::getParent(), I, llvm::Instruction::moveBefore(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), llvm::SmallVectorTemplateCommon< T >::rbegin(), and llvm::SmallVectorTemplateCommon< T >::rend().

bool llvm::SCEVExpander::isHighCostExpansion ( const SCEV Expr,
Loop L 
)
inline

Return true for expressions that may incur non-trivial cost to evaluate at runtime.

Definition at line 120 of file ScalarEvolutionExpander.h.

Referenced by canExpandBackedgeTakenCount(), and llvm::UnrollRuntimeLoopProlog().

bool llvm::SCEVExpander::isInsertedInstruction ( Instruction I) const
inline

Return true if the specified instruction was inserted by the code rewriter.

If so, the client should not modify the instruction.

Definition at line 190 of file ScalarEvolutionExpander.h.

unsigned SCEVExpander::replaceCongruentIVs ( Loop L,
const DominatorTree DT,
SmallVectorImpl< WeakVH > &  DeadInsts,
const TargetTransformInfo TTI = nullptr 
)
void llvm::SCEVExpander::setChainedPhi ( PHINode PN)
inline

Definition at line 194 of file ScalarEvolutionExpander.h.

void llvm::SCEVExpander::setDebugType ( const char *  s)
inline

Definition at line 105 of file ScalarEvolutionExpander.h.

void llvm::SCEVExpander::setIVIncInsertPos ( const Loop L,
Instruction Pos 
)
inline

Set the current IV increment loop and position.

Definition at line 150 of file ScalarEvolutionExpander.h.

void llvm::SCEVExpander::setPostInc ( const PostIncLoopSet L)
inline

Enable post-inc expansion for addrecs referring to the given loops.

Post-inc expansion is only supported in non-canonical mode.

Definition at line 159 of file ScalarEvolutionExpander.h.

Friends And Related Function Documentation

friend struct SCEVVisitor< SCEVExpander, Value * >
friend

Definition at line 90 of file ScalarEvolutionExpander.h.


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