14 #ifndef LLVM_ANALYSIS_SCALAREVOLUTIONEXPANDER_H 15 #define LLVM_ANALYSIS_SCALAREVOLUTIONEXPANDER_H 27 class TargetTransformInfo;
72 const Loop *IVIncInsertLoop;
99 class SCEVInsertPointGuard {
106 SCEVInsertPointGuard(
const SCEVInsertPointGuard &) =
delete;
107 SCEVInsertPointGuard &operator=(
const SCEVInsertPointGuard &) =
delete;
116 ~SCEVInsertPointGuard() {
135 const char *DebugType;
144 : SE(se), DL(DL), IVName(name), IVIncInsertLoop(nullptr),
145 IVIncInsertPos(nullptr), CanonicalMode(
true), LSRMode(
false),
165 InsertedExpressions.
clear();
166 InsertedValues.
clear();
167 InsertedPostIncValues.
clear();
180 return isHighCostExpansionHelper(Expr, L, At, Processed);
239 "IV increment positions are not supported in CanonicalMode");
241 IVIncInsertPos = Pos;
248 "Post-inc expansion is not supported in CanonicalMode");
254 PostIncLoops.
clear();
258 InsertedPostIncValues.
clear();
286 return InsertedValues.
count(I) || InsertedPostIncValues.
count(I);
314 bool isHighCostExpansionHelper(
const SCEV *S,
Loop *L,
335 Value *expandAddToGEP(
const SCEV *
const *op_begin,
336 const SCEV *
const *op_end,
341 ScalarEvolution::ValueOffsetPair
347 const Loop *getRelevantLoop(
const SCEV *);
375 void rememberInstruction(
Value *I);
389 Type *ExpandTy,
Type *IntTy,
bool useSubtract);
Common base class shared among various IRBuilders.
A parsed version of the target data layout string in and methods for querying it. ...
bool hoistIVInc(Instruction *IncV, Instruction *InsertPos)
Utility for hoisting an IV increment.
Value * getExactExistingExpansion(const SCEV *S, const Instruction *At, Loop *L)
Try to find existing LLVM IR value for S available at the point At.
This class represents lattice values for constants.
bool isSafeToExpandAt(const SCEV *S, const Instruction *InsertionPoint, ScalarEvolution &SE)
Return true if the given expression is safe to expand in the sense that all materialized values are d...
Implements a dense probed hash-table based set.
void push_back(const T &Elt)
The main scalar evolution driver.
bool isHighCostExpansion(const SCEV *Expr, Loop *L, const Instruction *At=nullptr)
Return true for expressions that may incur non-trivial cost to evaluate at runtime.
Optional< ScalarEvolution::ValueOffsetPair > getRelatedExistingExpansion(const SCEV *S, const Instruction *At, Loop *L)
Try to find the ValueOffsetPair for S.
This class represents a truncation of an integer value to a smaller integer value.
void setDebugType(const char *s)
Value * expandWrapPredicate(const SCEVWrapPredicate *P, Instruction *Loc)
A specialized variant of expandCodeForPredicate, handling the case when we are expanding code for a S...
block Block Frequency true
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
Value * expandCodeForPredicate(const SCEVPredicate *Pred, Instruction *Loc)
Generates a code sequence that evaluates this predicate.
void clearPostInc()
Disable all post-inc expansion.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
LLVMContext & getContext() const
const DebugLoc & getCurrentDebugLocation() const
Get location information used by debugging information.
This node represents multiplication of some number of SCEVs.
Value * generateOverflowCheck(const SCEVAddRecExpr *AR, Instruction *Loc, bool Signed)
Generates code that evaluates if the AR expression will overflow.
ConstantInt * getValue() const
This node represents a polynomial recurrence on the trip count of the specified loop.
BasicBlock * GetInsertBlock() const
void ClearInsertionPoint()
Clear the insertion point: created instructions will not be inserted into a block.
TargetFolder - Create constants with target dependent folding.
void SetCurrentDebugLocation(DebugLoc L)
Set location information used by debugging information.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
void SetInsertPoint(BasicBlock *TheBB)
This specifies that created instructions should be appended to the end of the specified block...
Class to represent pointers.
void clearInsertPoint()
Clear the current insertion point.
void clear()
Erase the contents of the InsertedExpressions map so that users trying to expand the same expression ...
This means that we are dealing with an entirely unknown SCEV value, and only represent it as its LLVM...
void restoreIP(InsertPoint IP)
Sets the current insert point to a previously-saved location.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
This class defines a simple visitor class that may be used for various SCEV analysis purposes...
This class represents a binary unsigned division operation.
The instances of the Type class are immutable: once they are created, they are never changed...
This is an important class for using LLVM in a threaded context.
void setInsertPoint(Instruction *IP)
Set the current insertion point.
Value handle that tracks a Value across RAUW.
std::pair< iterator, bool > insert(const ValueT &V)
Value * expandCodeFor(const SCEV *SH, Type *Ty, Instruction *I)
Insert code to directly compute the specified SCEV expression into the program.
static Expected< BitVector > expand(StringRef S, StringRef Original)
SCEVExpander(ScalarEvolution &se, const DataLayout &DL, const char *name)
Construct a SCEVExpander in "canonical" mode.
This class represents an assumption made using SCEV expressions which can be checked at run-time...
void setChainedPhi(PHINode *PN)
InsertPoint - A saved insertion point.
PHINode * getOrInsertCanonicalInductionVariable(const Loop *L, Type *Ty)
This method returns the canonical induction variable of the specified type for the specified loop (in...
void setIVIncInsertPos(const Loop *L, Instruction *Pos)
Set the current IV increment loop and position.
Value handle that asserts if the Value is deleted.
bool isInsertedInstruction(Instruction *I) const
Return true if the specified instruction was inserted by the code rewriter.
This node represents an addition of some number of SCEVs.
This class represents a signed maximum selection.
InstListType::iterator iterator
Instruction iterators...
Value * expandUnionPredicate(const SCEVUnionPredicate *Pred, Instruction *Loc)
A specialized variant of expandCodeForPredicate, handling the case when we are expanding code for a S...
This class uses information about analyze scalars to rewrite expressions in canonical form...
This class represents a zero extension of a small integer value to a larger integer value...
This class represents an analyzed expression in the program.
LLVM_NODISCARD bool empty() const
Represents a single loop in the control flow graph.
This class represents a sign extension of a small integer value to a larger integer value...
This class represents an unsigned maximum selection.
Instruction * getIVIncOperand(Instruction *IncV, Instruction *InsertPos, bool allowScale)
Return the induction variable increment's IV operand.
size_type count(const_arg_type_t< ValueT > V) const
Return 1 if the specified key is in the set, 0 otherwise.
unsigned replaceCongruentIVs(Loop *L, const DominatorTree *DT, SmallVectorImpl< WeakTrackingVH > &DeadInsts, const TargetTransformInfo *TTI=nullptr)
replace congruent phis with their most canonical representative.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This class represents a composition of other SCEV predicates, and is the class that most clients will...
Value * expandEqualPredicate(const SCEVEqualPredicate *Pred, Instruction *Loc)
A specialized variant of expandCodeForPredicate, handling the case when we are expanding code for a S...
LLVM Value Representation.
BasicBlock::iterator GetInsertPoint() const
void disableCanonicalMode()
Disable the behavior of expanding expressions in canonical form rather than in a more literal form...
This class represents an assumption made on an AddRec expression.
void setPostInc(const PostIncLoopSet &L)
Enable post-inc expansion for addrecs referring to the given loops.
bool isSafeToExpand(const SCEV *S, ScalarEvolution &SE)
Return true if the given expression is safe to expand in the sense that all materialized values are s...
This class represents an assumption that two SCEV expressions are equal, and this can be checked at r...
This class represents a constant integer value.