14 #ifndef LLVM_ANALYSIS_SCALAREVOLUTIONEXPANDER_H
15 #define LLVM_ANALYSIS_SCALAREVOLUTIONEXPANDER_H
25 class TargetTransformInfo;
47 std::set<AssertingVH<Value> > InsertedValues;
48 std::set<AssertingVH<Value> > InsertedPostIncValues;
63 const Loop *IVIncInsertLoop;
70 std::set<AssertingVH<PHINode> > ChainedPhis;
87 const char *DebugType;
95 : SE(se), IVName(name), IVIncInsertLoop(0), IVIncInsertPos(0),
111 InsertedExpressions.clear();
112 InsertedValues.clear();
113 InsertedPostIncValues.clear();
143 assert(!CanonicalMode &&
144 "IV increment positions are not supported in CanonicalMode");
146 IVIncInsertPos = Pos;
153 assert(!CanonicalMode &&
154 "Post-inc expansion is not supported in CanonicalMode");
160 PostIncLoops.
clear();
164 InsertedPostIncValues.clear();
185 return InsertedValues.count(I) || InsertedPostIncValues.count(I);
201 Value *ReuseOrCreateCast(Value *V,
Type *Ty,
208 Value *InsertNoopCastOfTo(Value *V,
Type *Ty);
212 Value *expandAddToGEP(
const SCEV *
const *op_begin,
213 const SCEV *
const *op_end,
214 PointerType *PTy,
Type *Ty, Value *V);
216 Value *expand(
const SCEV *S);
225 const Loop *getRelevantLoop(
const SCEV *);
227 Value *visitConstant(
const SCEVConstant *S) {
228 return S->getValue();
231 Value *visitTruncateExpr(
const SCEVTruncateExpr *S);
233 Value *visitZeroExtendExpr(
const SCEVZeroExtendExpr *S);
235 Value *visitSignExtendExpr(
const SCEVSignExtendExpr *S);
237 Value *visitAddExpr(
const SCEVAddExpr *S);
239 Value *visitMulExpr(
const SCEVMulExpr *S);
241 Value *visitUDivExpr(
const SCEVUDivExpr *S);
243 Value *visitAddRecExpr(
const SCEVAddRecExpr *S);
245 Value *visitSMaxExpr(
const SCEVSMaxExpr *S);
247 Value *visitUMaxExpr(
const SCEVUMaxExpr *S);
249 Value *visitUnknown(
const SCEVUnknown *S) {
250 return S->getValue();
253 void rememberInstruction(Value *
I);
255 bool isNormalAddRecExprPHI(PHINode *PN, Instruction *IncV,
const Loop *L);
257 bool isExpandedAddRecExprPHI(PHINode *PN, Instruction *IncV,
const Loop *L);
259 Value *expandAddRecExprLiterally(
const SCEVAddRecExpr *);
260 PHINode *getAddRecExprPHILiterally(
const SCEVAddRecExpr *Normalized,
264 Value *expandIVInc(PHINode *PN, Value *StepV,
const Loop *L,
265 Type *ExpandTy,
Type *IntTy,
bool useSubtract);
COFF::RelocationTypeX86 Type
bool hoistIVInc(Instruction *IncV, Instruction *InsertPos)
hoistIVInc - Utility for hoisting an IV increment.
LLVMContext & getContext() const
void setDebugType(const char *s)
void clearPostInc()
clearPostInc - Disable all post-inc expansion.
void ClearInsertionPoint()
Clear the insertion point: created instructions will not be inserted into a block.
TargetFolder - Create constants with target dependent folding.
Instr is a loop (backwards branch).
Value * expandCodeFor(const SCEV *SH, Type *Ty, Instruction *I)
unsigned replaceCongruentIVs(Loop *L, const DominatorTree *DT, SmallVectorImpl< WeakVH > &DeadInsts, const TargetTransformInfo *TTI=NULL)
void setChainedPhi(PHINode *PN)
PHINode * getOrInsertCanonicalInductionVariable(const Loop *L, Type *Ty)
void setIVIncInsertPos(const Loop *L, Instruction *Pos)
setIVIncInsertPos - Set the current IV increment loop and position.
Instruction * getIVIncOperand(Instruction *IncV, Instruction *InsertPos, bool allowScale)
getIVIncOperand - Return the induction variable increment's IV operand.
SCEVExpander(ScalarEvolution &se, const char *name)
SCEVExpander - Construct a SCEVExpander in "canonical" mode.
LLVM Value Representation.
bool isInsertedInstruction(Instruction *I) const
void disableCanonicalMode()
void setPostInc(const PostIncLoopSet &L)
bool isSafeToExpand(const SCEV *S, ScalarEvolution &SE)
InstListType::iterator iterator
Instruction iterators...
INITIALIZE_PASS(GlobalMerge,"global-merge","Global Merge", false, false) bool GlobalMerge const DataLayout * TD