48 if (!PN || !Operand)
return false;
67 class PostIncTransform {
78 Kind(kind),
Loops(loops), SE(se), DT(dt) {}
81 Value *OperandValToReplace);
85 Value *OperandValToReplace);
91 const SCEV *PostIncTransform::
95 const SCEV *O =
X->getOperand();
96 const SCEV *
N = TransformSubExpr(O, User, OperandValToReplace);
110 const Loop *L = AR->getLoop();
116 Operands.
push_back(TransformSubExpr(*
I, LUser,
nullptr));
132 if (AR->isAffine() &&
134 const SCEV *TransformedStep =
135 TransformSubExpr(AR->getStepRecurrence(SE),
136 User, OperandValToReplace);
137 Result = SE.getMinusSCEV(Result, TransformedStep);
145 assert(S == TransformSubExpr(Result, User, OperandValToReplace) &&
146 "SCEV normalization is not invertible!");
164 if (
Loops.count(L)) {
165 const SCEV *TransformedStep =
166 TransformSubExpr(AR->getStepRecurrence(SE),
167 User, OperandValToReplace);
168 Result = SE.getMinusSCEV(Result, TransformedStep);
172 assert(S == TransformSubExpr(Result, User, OperandValToReplace) &&
173 "SCEV normalization is not invertible!");
179 if (
Loops.count(L)) {
180 const SCEV *TransformedStep =
181 TransformSubExpr(AR->getStepRecurrence(SE),
182 User, OperandValToReplace);
183 Result = SE.getAddExpr(Result, TransformedStep);
192 bool Changed =
false;
197 const SCEV *N = TransformSubExpr(O, User, OperandValToReplace);
204 case scAddExpr:
return SE.getAddExpr(Operands);
205 case scMulExpr:
return SE.getMulExpr(Operands);
206 case scSMaxExpr:
return SE.getSMaxExpr(Operands);
207 case scUMaxExpr:
return SE.getUMaxExpr(Operands);
215 const SCEV *RO =
X->getRHS();
216 const SCEV *LN = TransformSubExpr(LO, User, OperandValToReplace);
217 const SCEV *
RN = TransformSubExpr(RO, User, OperandValToReplace);
218 if (LO != LN || RO != RN)
219 return SE.getUDivExpr(LN, RN);
228 const SCEV *PostIncTransform::
231 if (isa<SCEVConstant>(S) || isa<SCEVUnknown>(S))
234 const SCEV *Result = Transformed.lookup(S);
238 Result = TransformImpl(S, User, OperandValToReplace);
239 Transformed[S] = Result;
248 Value *OperandValToReplace,
252 PostIncTransform Transform(Kind, Loops, SE, DT);
253 return Transform.TransformSubExpr(S, User, OperandValToReplace);
void push_back(const T &Elt)
const SCEV * TransformForPostIncUse(TransformKind Kind, const SCEV *S, Instruction *User, Value *OperandValToReplace, PostIncLoopSet &Loops, ScalarEvolution &SE, DominatorTree &DT)
TransformForPostIncUse - Transform the given expression according to the given transformation kind...
ScalarEvolution - This class is the main scalar evolution driver.
Denormalize - Perform the inverse transform on the expression with the given loop set...
BlockT * getHeader() const
SCEVCastExpr - This is the base class for unary cast operator classes.
BlockT * getLoopLatch() const
getLoopLatch - If there is a single latch block for this loop, return it.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
const SCEV *const * op_iterator
SCEVAddRecExpr - This node represents a polynomial recurrence on the trip count of the specified loop...
NormalizeAutodetect - Detect post-inc opportunities on new expressions, update the given loop set...
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
unsigned getNumIncomingValues() const
getNumIncomingValues - Return the number of incoming edges
LLVM Basic Block Representation.
SCEVUDivExpr - This class represents a binary unsigned division operation.
Type * getType() const
getType - Return the LLVM type of this SCEV expression.
Normalize - Normalize according to the given loops.
BasicBlock * getIncomingBlock(unsigned i) const
getIncomingBlock - Return incoming basic block number i.
bool contains(const LoopT *L) const
contains - Return true if the specified loop is contained within in this loop.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang","erlang-compatible garbage collector")
TransformKind
TransformKind - Different types of transformations that TransformForPostIncUse can do...
bool dominates(const Instruction *Def, const Use &U) const
Return true if Def dominates a use in User.
Value * getIncomingValue(unsigned i) const
getIncomingValue - Return incoming value number x
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
LLVM_ATTRIBUTE_UNUSED_RESULT std::enable_if< !is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
SCEV - This class represents an analyzed expression in the program.
static bool IVUseShouldUsePostIncValue(Instruction *User, Value *Operand, const Loop *L, DominatorTree *DT)
IVUseShouldUsePostIncValue - We have discovered a "User" of an IV expression and now we need to decid...
const ARM::ArchExtKind Kind
unsigned getSCEVType() const
LLVM Value Representation.
SCEVNAryExpr - This node is a base class providing common functionality for n'ary operators...
const BasicBlock * getParent() const