1 //===- llvm/Analysis/ScalarEvolutionExpressions.h - SCEV Exprs --*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the classes used to represent and build scalar expressions.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_ANALYSIS_SCALAREVOLUTIONEXPRESSIONS_H
15 #define LLVM_ANALYSIS_SCALAREVOLUTIONEXPRESSIONS_H
17 #include "llvm/ADT/SmallPtrSet.h"
18 #include "llvm/ADT/iterator_range.h"
19 #include "llvm/Analysis/ScalarEvolution.h"
20 #include "llvm/Support/ErrorHandling.h"
28 // These should be ordered in terms of increasing complexity to make the
30 scConstant, scTruncate, scZeroExtend, scSignExtend, scAddExpr, scMulExpr,
31 scUDivExpr, scAddRecExpr, scUMaxExpr, scSMaxExpr,
32 scUnknown, scCouldNotCompute
35 //===--------------------------------------------------------------------===//
36 /// SCEVConstant - This class represents a constant integer value.
38 class SCEVConstant : public SCEV {
39 friend class ScalarEvolution;
42 SCEVConstant(const FoldingSetNodeIDRef ID, ConstantInt *v) :
43 SCEV(ID, scConstant), V(v) {}
45 ConstantInt *getValue() const { return V; }
46 const APInt &getAPInt() const { return getValue()->getValue(); }
48 Type *getType() const { return V->getType(); }
50 /// Methods for support type inquiry through isa, cast, and dyn_cast:
51 static inline bool classof(const SCEV *S) {
52 return S->getSCEVType() == scConstant;
56 //===--------------------------------------------------------------------===//
57 /// SCEVCastExpr - This is the base class for unary cast operator classes.
59 class SCEVCastExpr : public SCEV {
64 SCEVCastExpr(const FoldingSetNodeIDRef ID,
65 unsigned SCEVTy, const SCEV *op, Type *ty);
68 const SCEV *getOperand() const { return Op; }
69 Type *getType() const { return Ty; }
71 /// Methods for support type inquiry through isa, cast, and dyn_cast:
72 static inline bool classof(const SCEV *S) {
73 return S->getSCEVType() == scTruncate ||
74 S->getSCEVType() == scZeroExtend ||
75 S->getSCEVType() == scSignExtend;
79 //===--------------------------------------------------------------------===//
80 /// SCEVTruncateExpr - This class represents a truncation of an integer value
81 /// to a smaller integer value.
83 class SCEVTruncateExpr : public SCEVCastExpr {
84 friend class ScalarEvolution;
86 SCEVTruncateExpr(const FoldingSetNodeIDRef ID,
87 const SCEV *op, Type *ty);
90 /// Methods for support type inquiry through isa, cast, and dyn_cast:
91 static inline bool classof(const SCEV *S) {
92 return S->getSCEVType() == scTruncate;
96 //===--------------------------------------------------------------------===//
97 /// SCEVZeroExtendExpr - This class represents a zero extension of a small
98 /// integer value to a larger integer value.
100 class SCEVZeroExtendExpr : public SCEVCastExpr {
101 friend class ScalarEvolution;
103 SCEVZeroExtendExpr(const FoldingSetNodeIDRef ID,
104 const SCEV *op, Type *ty);
107 /// Methods for support type inquiry through isa, cast, and dyn_cast:
108 static inline bool classof(const SCEV *S) {
109 return S->getSCEVType() == scZeroExtend;
113 //===--------------------------------------------------------------------===//
114 /// SCEVSignExtendExpr - This class represents a sign extension of a small
115 /// integer value to a larger integer value.
117 class SCEVSignExtendExpr : public SCEVCastExpr {
118 friend class ScalarEvolution;
120 SCEVSignExtendExpr(const FoldingSetNodeIDRef ID,
121 const SCEV *op, Type *ty);
124 /// Methods for support type inquiry through isa, cast, and dyn_cast:
125 static inline bool classof(const SCEV *S) {
126 return S->getSCEVType() == scSignExtend;
131 //===--------------------------------------------------------------------===//
132 /// SCEVNAryExpr - This node is a base class providing common
133 /// functionality for n'ary operators.
135 class SCEVNAryExpr : public SCEV {
137 // Since SCEVs are immutable, ScalarEvolution allocates operand
138 // arrays with its SCEVAllocator, so this class just needs a simple
139 // pointer rather than a more elaborate vector-like data structure.
140 // This also avoids the need for a non-trivial destructor.
141 const SCEV *const *Operands;
144 SCEVNAryExpr(const FoldingSetNodeIDRef ID,
145 enum SCEVTypes T, const SCEV *const *O, size_t N)
146 : SCEV(ID, T), Operands(O), NumOperands(N) {}
149 size_t getNumOperands() const { return NumOperands; }
150 const SCEV *getOperand(unsigned i) const {
151 assert(i < NumOperands && "Operand index out of range!");
155 typedef const SCEV *const *op_iterator;
156 typedef iterator_range<op_iterator> op_range;
157 op_iterator op_begin() const { return Operands; }
158 op_iterator op_end() const { return Operands + NumOperands; }
159 op_range operands() const {
160 return make_range(op_begin(), op_end());
163 Type *getType() const { return getOperand(0)->getType(); }
165 NoWrapFlags getNoWrapFlags(NoWrapFlags Mask = NoWrapMask) const {
166 return (NoWrapFlags)(SubclassData & Mask);
169 /// Methods for support type inquiry through isa, cast, and dyn_cast:
170 static inline bool classof(const SCEV *S) {
171 return S->getSCEVType() == scAddExpr ||
172 S->getSCEVType() == scMulExpr ||
173 S->getSCEVType() == scSMaxExpr ||
174 S->getSCEVType() == scUMaxExpr ||
175 S->getSCEVType() == scAddRecExpr;
179 //===--------------------------------------------------------------------===//
180 /// SCEVCommutativeExpr - This node is the base class for n'ary commutative
183 class SCEVCommutativeExpr : public SCEVNAryExpr {
185 SCEVCommutativeExpr(const FoldingSetNodeIDRef ID,
186 enum SCEVTypes T, const SCEV *const *O, size_t N)
187 : SCEVNAryExpr(ID, T, O, N) {}
190 /// Methods for support type inquiry through isa, cast, and dyn_cast:
191 static inline bool classof(const SCEV *S) {
192 return S->getSCEVType() == scAddExpr ||
193 S->getSCEVType() == scMulExpr ||
194 S->getSCEVType() == scSMaxExpr ||
195 S->getSCEVType() == scUMaxExpr;
198 /// Set flags for a non-recurrence without clearing previously set flags.
199 void setNoWrapFlags(NoWrapFlags Flags) {
200 SubclassData |= Flags;
205 //===--------------------------------------------------------------------===//
206 /// SCEVAddExpr - This node represents an addition of some number of SCEVs.
208 class SCEVAddExpr : public SCEVCommutativeExpr {
209 friend class ScalarEvolution;
211 SCEVAddExpr(const FoldingSetNodeIDRef ID,
212 const SCEV *const *O, size_t N)
213 : SCEVCommutativeExpr(ID, scAddExpr, O, N) {
217 Type *getType() const {
218 // Use the type of the last operand, which is likely to be a pointer
219 // type, if there is one. This doesn't usually matter, but it can help
220 // reduce casts when the expressions are expanded.
221 return getOperand(getNumOperands() - 1)->getType();
224 /// Methods for support type inquiry through isa, cast, and dyn_cast:
225 static inline bool classof(const SCEV *S) {
226 return S->getSCEVType() == scAddExpr;
230 //===--------------------------------------------------------------------===//
231 /// SCEVMulExpr - This node represents multiplication of some number of SCEVs.
233 class SCEVMulExpr : public SCEVCommutativeExpr {
234 friend class ScalarEvolution;
236 SCEVMulExpr(const FoldingSetNodeIDRef ID,
237 const SCEV *const *O, size_t N)
238 : SCEVCommutativeExpr(ID, scMulExpr, O, N) {
242 /// Methods for support type inquiry through isa, cast, and dyn_cast:
243 static inline bool classof(const SCEV *S) {
244 return S->getSCEVType() == scMulExpr;
249 //===--------------------------------------------------------------------===//
250 /// SCEVUDivExpr - This class represents a binary unsigned division operation.
252 class SCEVUDivExpr : public SCEV {
253 friend class ScalarEvolution;
257 SCEVUDivExpr(const FoldingSetNodeIDRef ID, const SCEV *lhs, const SCEV *rhs)
258 : SCEV(ID, scUDivExpr), LHS(lhs), RHS(rhs) {}
261 const SCEV *getLHS() const { return LHS; }
262 const SCEV *getRHS() const { return RHS; }
264 Type *getType() const {
265 // In most cases the types of LHS and RHS will be the same, but in some
266 // crazy cases one or the other may be a pointer. ScalarEvolution doesn't
267 // depend on the type for correctness, but handling types carefully can
268 // avoid extra casts in the SCEVExpander. The LHS is more likely to be
269 // a pointer type than the RHS, so use the RHS' type here.
270 return getRHS()->getType();
273 /// Methods for support type inquiry through isa, cast, and dyn_cast:
274 static inline bool classof(const SCEV *S) {
275 return S->getSCEVType() == scUDivExpr;
280 //===--------------------------------------------------------------------===//
281 /// SCEVAddRecExpr - This node represents a polynomial recurrence on the trip
282 /// count of the specified loop. This is the primary focus of the
283 /// ScalarEvolution framework; all the other SCEV subclasses are mostly just
284 /// supporting infrastructure to allow SCEVAddRecExpr expressions to be
285 /// created and analyzed.
287 /// All operands of an AddRec are required to be loop invariant.
289 class SCEVAddRecExpr : public SCEVNAryExpr {
290 friend class ScalarEvolution;
294 SCEVAddRecExpr(const FoldingSetNodeIDRef ID,
295 const SCEV *const *O, size_t N, const Loop *l)
296 : SCEVNAryExpr(ID, scAddRecExpr, O, N), L(l) {}
299 const SCEV *getStart() const { return Operands[0]; }
300 const Loop *getLoop() const { return L; }
302 /// getStepRecurrence - This method constructs and returns the recurrence
303 /// indicating how much this expression steps by. If this is a polynomial
304 /// of degree N, it returns a chrec of degree N-1.
305 /// We cannot determine whether the step recurrence has self-wraparound.
306 const SCEV *getStepRecurrence(ScalarEvolution &SE) const {
307 if (isAffine()) return getOperand(1);
308 return SE.getAddRecExpr(SmallVector<const SCEV *, 3>(op_begin()+1,
310 getLoop(), FlagAnyWrap);
313 /// isAffine - Return true if this represents an expression
314 /// A + B*x where A and B are loop invariant values.
315 bool isAffine() const {
316 // We know that the start value is invariant. This expression is thus
317 // affine iff the step is also invariant.
318 return getNumOperands() == 2;
321 /// isQuadratic - Return true if this represents an expression
322 /// A + B*x + C*x^2 where A, B and C are loop invariant values.
323 /// This corresponds to an addrec of the form {L,+,M,+,N}
324 bool isQuadratic() const {
325 return getNumOperands() == 3;
328 /// Set flags for a recurrence without clearing any previously set flags.
329 /// For AddRec, either NUW or NSW implies NW. Keep track of this fact here
330 /// to make it easier to propagate flags.
331 void setNoWrapFlags(NoWrapFlags Flags) {
332 if (Flags & (FlagNUW | FlagNSW))
333 Flags = ScalarEvolution::setFlags(Flags, FlagNW);
334 SubclassData |= Flags;
337 /// evaluateAtIteration - Return the value of this chain of recurrences at
338 /// the specified iteration number.
339 const SCEV *evaluateAtIteration(const SCEV *It, ScalarEvolution &SE) const;
341 /// getNumIterationsInRange - Return the number of iterations of this loop
342 /// that produce values in the specified constant range. Another way of
343 /// looking at this is that it returns the first iteration number where the
344 /// value is not in the condition, thus computing the exit count. If the
345 /// iteration count can't be computed, an instance of SCEVCouldNotCompute is
347 const SCEV *getNumIterationsInRange(ConstantRange Range,
348 ScalarEvolution &SE) const;
350 /// getPostIncExpr - Return an expression representing the value of
351 /// this expression one iteration of the loop ahead.
352 const SCEVAddRecExpr *getPostIncExpr(ScalarEvolution &SE) const {
353 return cast<SCEVAddRecExpr>(SE.getAddExpr(this, getStepRecurrence(SE)));
356 /// Methods for support type inquiry through isa, cast, and dyn_cast:
357 static inline bool classof(const SCEV *S) {
358 return S->getSCEVType() == scAddRecExpr;
362 //===--------------------------------------------------------------------===//
363 /// SCEVSMaxExpr - This class represents a signed maximum selection.
365 class SCEVSMaxExpr : public SCEVCommutativeExpr {
366 friend class ScalarEvolution;
368 SCEVSMaxExpr(const FoldingSetNodeIDRef ID,
369 const SCEV *const *O, size_t N)
370 : SCEVCommutativeExpr(ID, scSMaxExpr, O, N) {
371 // Max never overflows.
372 setNoWrapFlags((NoWrapFlags)(FlagNUW | FlagNSW));
376 /// Methods for support type inquiry through isa, cast, and dyn_cast:
377 static inline bool classof(const SCEV *S) {
378 return S->getSCEVType() == scSMaxExpr;
383 //===--------------------------------------------------------------------===//
384 /// SCEVUMaxExpr - This class represents an unsigned maximum selection.
386 class SCEVUMaxExpr : public SCEVCommutativeExpr {
387 friend class ScalarEvolution;
389 SCEVUMaxExpr(const FoldingSetNodeIDRef ID,
390 const SCEV *const *O, size_t N)
391 : SCEVCommutativeExpr(ID, scUMaxExpr, O, N) {
392 // Max never overflows.
393 setNoWrapFlags((NoWrapFlags)(FlagNUW | FlagNSW));
397 /// Methods for support type inquiry through isa, cast, and dyn_cast:
398 static inline bool classof(const SCEV *S) {
399 return S->getSCEVType() == scUMaxExpr;
403 //===--------------------------------------------------------------------===//
404 /// SCEVUnknown - This means that we are dealing with an entirely unknown SCEV
405 /// value, and only represent it as its LLVM Value. This is the "bottom"
406 /// value for the analysis.
408 class SCEVUnknown final : public SCEV, private CallbackVH {
409 friend class ScalarEvolution;
411 // Implement CallbackVH.
412 void deleted() override;
413 void allUsesReplacedWith(Value *New) override;
415 /// SE - The parent ScalarEvolution value. This is used to update
416 /// the parent's maps when the value associated with a SCEVUnknown
417 /// is deleted or RAUW'd.
420 /// Next - The next pointer in the linked list of all
421 /// SCEVUnknown instances owned by a ScalarEvolution.
424 SCEVUnknown(const FoldingSetNodeIDRef ID, Value *V,
425 ScalarEvolution *se, SCEVUnknown *next) :
426 SCEV(ID, scUnknown), CallbackVH(V), SE(se), Next(next) {}
429 Value *getValue() const { return getValPtr(); }
431 /// isSizeOf, isAlignOf, isOffsetOf - Test whether this is a special
432 /// constant representing a type size, alignment, or field offset in
433 /// a target-independent manner, and hasn't happened to have been
434 /// folded with other operations into something unrecognizable. This
435 /// is mainly only useful for pretty-printing and other situations
436 /// where it isn't absolutely required for these to succeed.
437 bool isSizeOf(Type *&AllocTy) const;
438 bool isAlignOf(Type *&AllocTy) const;
439 bool isOffsetOf(Type *&STy, Constant *&FieldNo) const;
441 Type *getType() const { return getValPtr()->getType(); }
443 /// Methods for support type inquiry through isa, cast, and dyn_cast:
444 static inline bool classof(const SCEV *S) {
445 return S->getSCEVType() == scUnknown;
449 /// SCEVVisitor - This class defines a simple visitor class that may be used
450 /// for various SCEV analysis purposes.
451 template<typename SC, typename RetVal=void>
453 RetVal visit(const SCEV *S) {
454 switch (S->getSCEVType()) {
456 return ((SC*)this)->visitConstant((const SCEVConstant*)S);
458 return ((SC*)this)->visitTruncateExpr((const SCEVTruncateExpr*)S);
460 return ((SC*)this)->visitZeroExtendExpr((const SCEVZeroExtendExpr*)S);
462 return ((SC*)this)->visitSignExtendExpr((const SCEVSignExtendExpr*)S);
464 return ((SC*)this)->visitAddExpr((const SCEVAddExpr*)S);
466 return ((SC*)this)->visitMulExpr((const SCEVMulExpr*)S);
468 return ((SC*)this)->visitUDivExpr((const SCEVUDivExpr*)S);
470 return ((SC*)this)->visitAddRecExpr((const SCEVAddRecExpr*)S);
472 return ((SC*)this)->visitSMaxExpr((const SCEVSMaxExpr*)S);
474 return ((SC*)this)->visitUMaxExpr((const SCEVUMaxExpr*)S);
476 return ((SC*)this)->visitUnknown((const SCEVUnknown*)S);
477 case scCouldNotCompute:
478 return ((SC*)this)->visitCouldNotCompute((const SCEVCouldNotCompute*)S);
480 llvm_unreachable("Unknown SCEV type!");
484 RetVal visitCouldNotCompute(const SCEVCouldNotCompute *S) {
485 llvm_unreachable("Invalid use of SCEVCouldNotCompute!");
489 /// Visit all nodes in the expression tree using worklist traversal.
491 /// Visitor implements:
492 /// // return true to follow this node.
493 /// bool follow(const SCEV *S);
494 /// // return true to terminate the search.
496 template<typename SV>
497 class SCEVTraversal {
499 SmallVector<const SCEV *, 8> Worklist;
500 SmallPtrSet<const SCEV *, 8> Visited;
502 void push(const SCEV *S) {
503 if (Visited.insert(S).second && Visitor.follow(S))
504 Worklist.push_back(S);
507 SCEVTraversal(SV& V): Visitor(V) {}
509 void visitAll(const SCEV *Root) {
511 while (!Worklist.empty() && !Visitor.isDone()) {
512 const SCEV *S = Worklist.pop_back_val();
514 switch (S->getSCEVType()) {
521 push(cast<SCEVCastExpr>(S)->getOperand());
528 const SCEVNAryExpr *NAry = cast<SCEVNAryExpr>(S);
529 for (SCEVNAryExpr::op_iterator I = NAry->op_begin(),
530 E = NAry->op_end(); I != E; ++I) {
536 const SCEVUDivExpr *UDiv = cast<SCEVUDivExpr>(S);
537 push(UDiv->getLHS());
538 push(UDiv->getRHS());
541 case scCouldNotCompute:
542 llvm_unreachable("Attempt to use a SCEVCouldNotCompute object!");
544 llvm_unreachable("Unknown SCEV kind!");
550 /// Use SCEVTraversal to visit all nodes in the given expression tree.
551 template<typename SV>
552 void visitAll(const SCEV *Root, SV& Visitor) {
553 SCEVTraversal<SV> T(Visitor);
557 /// Recursively visits a SCEV expression and re-writes it.
558 template<typename SC>
559 class SCEVRewriteVisitor : public SCEVVisitor<SC, const SCEV *> {
563 SCEVRewriteVisitor(ScalarEvolution &SE) : SE(SE) {}
565 const SCEV *visitConstant(const SCEVConstant *Constant) {
569 const SCEV *visitTruncateExpr(const SCEVTruncateExpr *Expr) {
570 const SCEV *Operand = ((SC*)this)->visit(Expr->getOperand());
571 return SE.getTruncateExpr(Operand, Expr->getType());
574 const SCEV *visitZeroExtendExpr(const SCEVZeroExtendExpr *Expr) {
575 const SCEV *Operand = ((SC*)this)->visit(Expr->getOperand());
576 return SE.getZeroExtendExpr(Operand, Expr->getType());
579 const SCEV *visitSignExtendExpr(const SCEVSignExtendExpr *Expr) {
580 const SCEV *Operand = ((SC*)this)->visit(Expr->getOperand());
581 return SE.getSignExtendExpr(Operand, Expr->getType());
584 const SCEV *visitAddExpr(const SCEVAddExpr *Expr) {
585 SmallVector<const SCEV *, 2> Operands;
586 for (int i = 0, e = Expr->getNumOperands(); i < e; ++i)
587 Operands.push_back(((SC*)this)->visit(Expr->getOperand(i)));
588 return SE.getAddExpr(Operands);
591 const SCEV *visitMulExpr(const SCEVMulExpr *Expr) {
592 SmallVector<const SCEV *, 2> Operands;
593 for (int i = 0, e = Expr->getNumOperands(); i < e; ++i)
594 Operands.push_back(((SC*)this)->visit(Expr->getOperand(i)));
595 return SE.getMulExpr(Operands);
598 const SCEV *visitUDivExpr(const SCEVUDivExpr *Expr) {
599 return SE.getUDivExpr(((SC*)this)->visit(Expr->getLHS()),
600 ((SC*)this)->visit(Expr->getRHS()));
603 const SCEV *visitAddRecExpr(const SCEVAddRecExpr *Expr) {
604 SmallVector<const SCEV *, 2> Operands;
605 for (int i = 0, e = Expr->getNumOperands(); i < e; ++i)
606 Operands.push_back(((SC*)this)->visit(Expr->getOperand(i)));
607 return SE.getAddRecExpr(Operands, Expr->getLoop(),
608 Expr->getNoWrapFlags());
611 const SCEV *visitSMaxExpr(const SCEVSMaxExpr *Expr) {
612 SmallVector<const SCEV *, 2> Operands;
613 for (int i = 0, e = Expr->getNumOperands(); i < e; ++i)
614 Operands.push_back(((SC*)this)->visit(Expr->getOperand(i)));
615 return SE.getSMaxExpr(Operands);
618 const SCEV *visitUMaxExpr(const SCEVUMaxExpr *Expr) {
619 SmallVector<const SCEV *, 2> Operands;
620 for (int i = 0, e = Expr->getNumOperands(); i < e; ++i)
621 Operands.push_back(((SC*)this)->visit(Expr->getOperand(i)));
622 return SE.getUMaxExpr(Operands);
625 const SCEV *visitUnknown(const SCEVUnknown *Expr) {
629 const SCEV *visitCouldNotCompute(const SCEVCouldNotCompute *Expr) {
634 typedef DenseMap<const Value*, Value*> ValueToValueMap;
636 /// The SCEVParameterRewriter takes a scalar evolution expression and updates
637 /// the SCEVUnknown components following the Map (Value -> Value).
638 class SCEVParameterRewriter : public SCEVRewriteVisitor<SCEVParameterRewriter> {
640 static const SCEV *rewrite(const SCEV *Scev, ScalarEvolution &SE,
641 ValueToValueMap &Map,
642 bool InterpretConsts = false) {
643 SCEVParameterRewriter Rewriter(SE, Map, InterpretConsts);
644 return Rewriter.visit(Scev);
647 SCEVParameterRewriter(ScalarEvolution &SE, ValueToValueMap &M, bool C)
648 : SCEVRewriteVisitor(SE), Map(M), InterpretConsts(C) {}
650 const SCEV *visitUnknown(const SCEVUnknown *Expr) {
651 Value *V = Expr->getValue();
654 if (InterpretConsts && isa<ConstantInt>(NV))
655 return SE.getConstant(cast<ConstantInt>(NV));
656 return SE.getUnknown(NV);
662 ValueToValueMap ⤅
663 bool InterpretConsts;
666 typedef DenseMap<const Loop*, const SCEV*> LoopToScevMapT;
668 /// The SCEVLoopAddRecRewriter takes a scalar evolution expression and applies
669 /// the Map (Loop -> SCEV) to all AddRecExprs.
670 class SCEVLoopAddRecRewriter
671 : public SCEVRewriteVisitor<SCEVLoopAddRecRewriter> {
673 static const SCEV *rewrite(const SCEV *Scev, LoopToScevMapT &Map,
674 ScalarEvolution &SE) {
675 SCEVLoopAddRecRewriter Rewriter(SE, Map);
676 return Rewriter.visit(Scev);
679 SCEVLoopAddRecRewriter(ScalarEvolution &SE, LoopToScevMapT &M)
680 : SCEVRewriteVisitor(SE), Map(M) {}
682 const SCEV *visitAddRecExpr(const SCEVAddRecExpr *Expr) {
683 SmallVector<const SCEV *, 2> Operands;
684 for (int i = 0, e = Expr->getNumOperands(); i < e; ++i)
685 Operands.push_back(visit(Expr->getOperand(i)));
687 const Loop *L = Expr->getLoop();
688 const SCEV *Res = SE.getAddRecExpr(Operands, L, Expr->getNoWrapFlags());
690 if (0 == Map.count(L))
693 const SCEVAddRecExpr *Rec = cast<SCEVAddRecExpr>(Res);
694 return Rec->evaluateAtIteration(Map[L], SE);
701 /// Applies the Map (Loop -> SCEV) to the given Scev.
702 static inline const SCEV *apply(const SCEV *Scev, LoopToScevMapT &Map,
703 ScalarEvolution &SE) {
704 return SCEVLoopAddRecRewriter::rewrite(Scev, Map, SE);