|
LLVM
3.7.0
|
This class uses information about analyze scalars to rewrite expressions in canonical form. More...
#include <ScalarEvolutionExpander.h>
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... | |
| PHINode * | 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). More... | |
| Instruction * | getIVIncOperand (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... | |
| Value * | expandCodeFor (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 * > | |
| Value * | visit (const SCEV *S) |
| Value * | visitCouldNotCompute (const SCEVCouldNotCompute *S) |
Friends | |
| struct | SCEVVisitor< SCEVExpander, Value * > |
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.
|
inlineexplicit |
Construct a SCEVExpander in "canonical" mode.
Definition at line 94 of file ScalarEvolutionExpander.h.
|
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.
|
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().
|
inline |
Disable all post-inc expansion.
Definition at line 166 of file ScalarEvolutionExpander.h.
References llvm::SmallPtrSetImplBase::clear().
|
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.
|
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().
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().
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().
|
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 |
||
| ) |
replace congruent phis with their most canonical representative.
replaceCongruentIVs - Check for congruent phis in this loop header and replace them with their most canonical representative.
Return the number of phis eliminated.
Return the number of phis eliminated.
This does not depend on any SCEVExpander state but should be used in the same context that SCEVExpander is used.
Definition at line 1692 of file ScalarEvolutionExpander.cpp.
References llvm::SmallVectorTemplateCommon< T >::back(), llvm::SmallVectorTemplateCommon< T >::begin(), llvm::dbgs(), DEBUG_WITH_TYPE, llvm::DL, llvm::dyn_cast(), llvm::SmallVectorImpl< T >::emplace_back(), llvm::SmallVectorTemplateCommon< T >::end(), llvm::Instruction::getDebugLoc(), llvm::BasicBlock::getFirstInsertionPt(), llvm::LoopBase< N, M >::getHeader(), llvm::PHINode::getIncomingValueForBlock(), llvm::LoopBase< N, M >::getLoopLatch(), llvm::ilist_node< NodeTy >::getNextNode(), llvm::Instruction::getParent(), llvm::Type::getPrimitiveSizeInBits(), llvm::Value::getType(), I, llvm::Type::isIntegerTy(), llvm::Type::isPointerTy(), llvm::TargetTransformInfo::isTruncateFree(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), llvm::Value::replaceAllUsesWith(), llvm::IRBuilderBase::SetCurrentDebugLocation(), llvm::SimplifyInstruction(), and std::swap().
|
inline |
Definition at line 194 of file ScalarEvolutionExpander.h.
|
inline |
Definition at line 105 of file ScalarEvolutionExpander.h.
|
inline |
Set the current IV increment loop and position.
Definition at line 150 of file ScalarEvolutionExpander.h.
|
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.
|
friend |
Definition at line 90 of file ScalarEvolutionExpander.h.
1.8.6