1 //===- llvm/Analysis/ScalarEvolution.h - Scalar Evolution -------*- 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 // The ScalarEvolution class is an LLVM pass which can be used to analyze and
11 // categorize scalar expressions in loops. It specializes in recognizing
12 // general induction variables, representing them with the abstract and opaque
13 // SCEV class. Given this analysis, trip counts of loops and other important
14 // properties can be obtained.
16 // This analysis is primarily useful for induction variable substitution and
17 // strength reduction.
19 //===----------------------------------------------------------------------===//
21 #ifndef LLVM_ANALYSIS_SCALAREVOLUTION_H
22 #define LLVM_ANALYSIS_SCALAREVOLUTION_H
24 #include "llvm/Pass.h"
25 #include "llvm/Instructions.h"
26 #include "llvm/Function.h"
27 #include "llvm/System/DataTypes.h"
28 #include "llvm/Support/ValueHandle.h"
29 #include "llvm/Support/Allocator.h"
30 #include "llvm/Support/ConstantRange.h"
31 #include "llvm/ADT/FoldingSet.h"
32 #include "llvm/ADT/DenseMap.h"
41 class ScalarEvolution;
48 /// SCEV - This class represents an analyzed expression in the program. These
49 /// are opaque objects that the client is not allowed to do much with
52 class SCEV : public FoldingSetNode {
53 /// FastID - A reference to an Interned FoldingSetNodeID for this node.
54 /// The ScalarEvolution's BumpPtrAllocator holds the data.
55 FoldingSetNodeIDRef FastID;
57 // The SCEV baseclass this node corresponds to
58 const unsigned short SCEVType;
61 /// SubclassData - This field is initialized to zero and may be used in
62 /// subclasses to store miscellaneous information.
63 unsigned short SubclassData;
66 SCEV(const SCEV &); // DO NOT IMPLEMENT
67 void operator=(const SCEV &); // DO NOT IMPLEMENT
71 explicit SCEV(const FoldingSetNodeIDRef ID, unsigned SCEVTy) :
72 FastID(ID), SCEVType(SCEVTy), SubclassData(0) {}
74 unsigned getSCEVType() const { return SCEVType; }
76 /// Profile - FoldingSet support.
77 void Profile(FoldingSetNodeID& ID) { ID = FastID; }
79 /// getProfile - Like Profile, but a different interface which doesn't copy.
80 const FoldingSetNodeIDRef &getProfile() const { return FastID; }
82 /// isLoopInvariant - Return true if the value of this SCEV is unchanging in
83 /// the specified loop.
84 virtual bool isLoopInvariant(const Loop *L) const = 0;
86 /// hasComputableLoopEvolution - Return true if this SCEV changes value in a
87 /// known way in the specified loop. This property being true implies that
88 /// the value is variant in the loop AND that we can emit an expression to
89 /// compute the value of the expression at any particular loop iteration.
90 virtual bool hasComputableLoopEvolution(const Loop *L) const = 0;
92 /// getType - Return the LLVM type of this SCEV expression.
94 virtual const Type *getType() const = 0;
96 /// isZero - Return true if the expression is a constant zero.
100 /// isOne - Return true if the expression is a constant one.
104 /// isAllOnesValue - Return true if the expression is a constant
107 bool isAllOnesValue() const;
109 /// hasOperand - Test whether this SCEV has Op as a direct or
110 /// indirect operand.
111 virtual bool hasOperand(const SCEV *Op) const = 0;
113 /// dominates - Return true if elements that makes up this SCEV dominates
114 /// the specified basic block.
115 virtual bool dominates(BasicBlock *BB, DominatorTree *DT) const = 0;
117 /// properlyDominates - Return true if elements that makes up this SCEV
118 /// properly dominate the specified basic block.
119 virtual bool properlyDominates(BasicBlock *BB, DominatorTree *DT) const = 0;
121 /// print - Print out the internal representation of this scalar to the
122 /// specified stream. This should really only be used for debugging
124 virtual void print(raw_ostream &OS) const = 0;
126 /// dump - This method is used for debugging.
131 inline raw_ostream &operator<<(raw_ostream &OS, const SCEV &S) {
136 /// SCEVCouldNotCompute - An object of this class is returned by queries that
137 /// could not be answered. For example, if you ask for the number of
138 /// iterations of a linked-list traversal loop, you will get one of these.
139 /// None of the standard SCEV operations are valid on this class, it is just a
141 struct SCEVCouldNotCompute : public SCEV {
142 SCEVCouldNotCompute();
144 // None of these methods are valid for this object.
145 virtual bool isLoopInvariant(const Loop *L) const;
146 virtual const Type *getType() const;
147 virtual bool hasComputableLoopEvolution(const Loop *L) const;
148 virtual void print(raw_ostream &OS) const;
149 virtual bool hasOperand(const SCEV *Op) const;
151 virtual bool dominates(BasicBlock *BB, DominatorTree *DT) const {
155 virtual bool properlyDominates(BasicBlock *BB, DominatorTree *DT) const {
159 /// Methods for support type inquiry through isa, cast, and dyn_cast:
160 static inline bool classof(const SCEVCouldNotCompute *S) { return true; }
161 static bool classof(const SCEV *S);
164 /// ScalarEvolution - This class is the main scalar evolution driver. Because
165 /// client code (intentionally) can't do much with the SCEV objects directly,
166 /// they must ask this class for services.
168 class ScalarEvolution : public FunctionPass {
169 /// SCEVCallbackVH - A CallbackVH to arrange for ScalarEvolution to be
170 /// notified whenever a Value is deleted.
171 class SCEVCallbackVH : public CallbackVH {
173 virtual void deleted();
174 virtual void allUsesReplacedWith(Value *New);
176 SCEVCallbackVH(Value *V, ScalarEvolution *SE = 0);
179 friend class SCEVCallbackVH;
180 friend class SCEVExpander;
182 /// F - The function we are analyzing.
186 /// LI - The loop information for the function we are currently analyzing.
190 /// TD - The target data information for the target we are targeting.
194 /// DT - The dominator tree.
198 /// CouldNotCompute - This SCEV is used to represent unknown trip
199 /// counts and things.
200 SCEVCouldNotCompute CouldNotCompute;
202 /// Scalars - This is a cache of the scalars we have analyzed so far.
204 std::map<SCEVCallbackVH, const SCEV *> Scalars;
206 /// BackedgeTakenInfo - Information about the backedge-taken count
207 /// of a loop. This currently includes an exact count and a maximum count.
209 struct BackedgeTakenInfo {
210 /// Exact - An expression indicating the exact backedge-taken count of
211 /// the loop if it is known, or a SCEVCouldNotCompute otherwise.
214 /// Max - An expression indicating the least maximum backedge-taken
215 /// count of the loop that is known, or a SCEVCouldNotCompute.
218 /*implicit*/ BackedgeTakenInfo(const SCEV *exact) :
219 Exact(exact), Max(exact) {}
221 BackedgeTakenInfo(const SCEV *exact, const SCEV *max) :
222 Exact(exact), Max(max) {}
224 /// hasAnyInfo - Test whether this BackedgeTakenInfo contains any
225 /// computed information, or whether it's all SCEVCouldNotCompute
227 bool hasAnyInfo() const {
228 return !isa<SCEVCouldNotCompute>(Exact) ||
229 !isa<SCEVCouldNotCompute>(Max);
233 /// BackedgeTakenCounts - Cache the backedge-taken count of the loops for
234 /// this function as they are computed.
235 std::map<const Loop*, BackedgeTakenInfo> BackedgeTakenCounts;
237 /// ConstantEvolutionLoopExitValue - This map contains entries for all of
238 /// the PHI instructions that we attempt to compute constant evolutions for.
239 /// This allows us to avoid potentially expensive recomputation of these
240 /// properties. An instruction maps to null if we are unable to compute its
242 std::map<PHINode*, Constant*> ConstantEvolutionLoopExitValue;
244 /// ValuesAtScopes - This map contains entries for all the expressions
245 /// that we attempt to compute getSCEVAtScope information for, which can
246 /// be expensive in extreme cases.
247 std::map<const SCEV *,
248 std::map<const Loop *, const SCEV *> > ValuesAtScopes;
250 /// createSCEV - We know that there is no SCEV for the specified value.
251 /// Analyze the expression.
252 const SCEV *createSCEV(Value *V);
254 /// createNodeForPHI - Provide the special handling we need to analyze PHI
256 const SCEV *createNodeForPHI(PHINode *PN);
258 /// createNodeForGEP - Provide the special handling we need to analyze GEP
260 const SCEV *createNodeForGEP(GEPOperator *GEP);
262 /// computeSCEVAtScope - Implementation code for getSCEVAtScope; called
263 /// at most once for each SCEV+Loop pair.
265 const SCEV *computeSCEVAtScope(const SCEV *S, const Loop *L);
267 /// ForgetSymbolicValue - This looks up computed SCEV values for all
268 /// instructions that depend on the given instruction and removes them from
269 /// the Scalars map if they reference SymName. This is used during PHI
271 void ForgetSymbolicName(Instruction *I, const SCEV *SymName);
273 /// getBECount - Subtract the end and start values and divide by the step,
274 /// rounding up, to get the number of times the backedge is executed. Return
275 /// CouldNotCompute if an intermediate computation overflows.
276 const SCEV *getBECount(const SCEV *Start,
281 /// getBackedgeTakenInfo - Return the BackedgeTakenInfo for the given
282 /// loop, lazily computing new values if the loop hasn't been analyzed
284 const BackedgeTakenInfo &getBackedgeTakenInfo(const Loop *L);
286 /// ComputeBackedgeTakenCount - Compute the number of times the specified
287 /// loop will iterate.
288 BackedgeTakenInfo ComputeBackedgeTakenCount(const Loop *L);
290 /// ComputeBackedgeTakenCountFromExit - Compute the number of times the
291 /// backedge of the specified loop will execute if it exits via the
293 BackedgeTakenInfo ComputeBackedgeTakenCountFromExit(const Loop *L,
294 BasicBlock *ExitingBlock);
296 /// ComputeBackedgeTakenCountFromExitCond - Compute the number of times the
297 /// backedge of the specified loop will execute if its exit condition
298 /// were a conditional branch of ExitCond, TBB, and FBB.
300 ComputeBackedgeTakenCountFromExitCond(const Loop *L,
305 /// ComputeBackedgeTakenCountFromExitCondICmp - Compute the number of
306 /// times the backedge of the specified loop will execute if its exit
307 /// condition were a conditional branch of the ICmpInst ExitCond, TBB,
310 ComputeBackedgeTakenCountFromExitCondICmp(const Loop *L,
315 /// ComputeLoadConstantCompareBackedgeTakenCount - Given an exit condition
316 /// of 'icmp op load X, cst', try to see if we can compute the
317 /// backedge-taken count.
319 ComputeLoadConstantCompareBackedgeTakenCount(LoadInst *LI,
322 ICmpInst::Predicate p);
324 /// ComputeBackedgeTakenCountExhaustively - If the loop is known to execute
325 /// a constant number of times (the condition evolves only from constants),
326 /// try to evaluate a few iterations of the loop until we get the exit
327 /// condition gets a value of ExitWhen (true or false). If we cannot
328 /// evaluate the backedge-taken count of the loop, return CouldNotCompute.
329 const SCEV *ComputeBackedgeTakenCountExhaustively(const Loop *L,
333 /// HowFarToZero - Return the number of times a backedge comparing the
334 /// specified value to zero will execute. If not computable, return
336 BackedgeTakenInfo HowFarToZero(const SCEV *V, const Loop *L);
338 /// HowFarToNonZero - Return the number of times a backedge checking the
339 /// specified value for nonzero will execute. If not computable, return
341 BackedgeTakenInfo HowFarToNonZero(const SCEV *V, const Loop *L);
343 /// HowManyLessThans - Return the number of times a backedge containing the
344 /// specified less-than comparison will execute. If not computable, return
345 /// CouldNotCompute. isSigned specifies whether the less-than is signed.
346 BackedgeTakenInfo HowManyLessThans(const SCEV *LHS, const SCEV *RHS,
347 const Loop *L, bool isSigned);
349 /// getLoopPredecessor - If the given loop's header has exactly one unique
350 /// predecessor outside the loop, return it. Otherwise return null.
351 BasicBlock *getLoopPredecessor(const Loop *L);
353 /// getPredecessorWithUniqueSuccessorForBB - Return a predecessor of BB
354 /// (which may not be an immediate predecessor) which has exactly one
355 /// successor from which BB is reachable, or null if no such block is
357 std::pair<BasicBlock *, BasicBlock *>
358 getPredecessorWithUniqueSuccessorForBB(BasicBlock *BB);
360 /// isImpliedCond - Test whether the condition described by Pred, LHS,
361 /// and RHS is true whenever the given Cond value evaluates to true.
362 bool isImpliedCond(Value *Cond, ICmpInst::Predicate Pred,
363 const SCEV *LHS, const SCEV *RHS,
366 /// isImpliedCondOperands - Test whether the condition described by Pred,
367 /// LHS, and RHS is true whenever the condition described by Pred, FoundLHS,
368 /// and FoundRHS is true.
369 bool isImpliedCondOperands(ICmpInst::Predicate Pred,
370 const SCEV *LHS, const SCEV *RHS,
371 const SCEV *FoundLHS, const SCEV *FoundRHS);
373 /// isImpliedCondOperandsHelper - Test whether the condition described by
374 /// Pred, LHS, and RHS is true whenever the condition described by Pred,
375 /// FoundLHS, and FoundRHS is true.
376 bool isImpliedCondOperandsHelper(ICmpInst::Predicate Pred,
377 const SCEV *LHS, const SCEV *RHS,
378 const SCEV *FoundLHS, const SCEV *FoundRHS);
380 /// getConstantEvolutionLoopExitValue - If we know that the specified Phi is
381 /// in the header of its containing loop, we know the loop executes a
382 /// constant number of times, and the PHI node is just a recurrence
383 /// involving constants, fold it.
384 Constant *getConstantEvolutionLoopExitValue(PHINode *PN, const APInt& BEs,
387 /// isKnownPredicateWithRanges - Test if the given expression is known to
388 /// satisfy the condition described by Pred and the known constant ranges
391 bool isKnownPredicateWithRanges(ICmpInst::Predicate Pred,
392 const SCEV *LHS, const SCEV *RHS);
395 static char ID; // Pass identification, replacement for typeid
398 LLVMContext &getContext() const { return F->getContext(); }
400 /// isSCEVable - Test if values of the given type are analyzable within
401 /// the SCEV framework. This primarily includes integer types, and it
402 /// can optionally include pointer types if the ScalarEvolution class
403 /// has access to target-specific information.
404 bool isSCEVable(const Type *Ty) const;
406 /// getTypeSizeInBits - Return the size in bits of the specified type,
407 /// for which isSCEVable must return true.
408 uint64_t getTypeSizeInBits(const Type *Ty) const;
410 /// getEffectiveSCEVType - Return a type with the same bitwidth as
411 /// the given type and which represents how SCEV will treat the given
412 /// type, for which isSCEVable must return true. For pointer types,
413 /// this is the pointer-sized integer type.
414 const Type *getEffectiveSCEVType(const Type *Ty) const;
416 /// getSCEV - Return a SCEV expression for the full generality of the
417 /// specified expression.
418 const SCEV *getSCEV(Value *V);
420 const SCEV *getConstant(ConstantInt *V);
421 const SCEV *getConstant(const APInt& Val);
422 const SCEV *getConstant(const Type *Ty, uint64_t V, bool isSigned = false);
423 const SCEV *getTruncateExpr(const SCEV *Op, const Type *Ty);
424 const SCEV *getZeroExtendExpr(const SCEV *Op, const Type *Ty);
425 const SCEV *getSignExtendExpr(const SCEV *Op, const Type *Ty);
426 const SCEV *getAnyExtendExpr(const SCEV *Op, const Type *Ty);
427 const SCEV *getAddExpr(SmallVectorImpl<const SCEV *> &Ops,
428 bool HasNUW = false, bool HasNSW = false);
429 const SCEV *getAddExpr(const SCEV *LHS, const SCEV *RHS,
430 bool HasNUW = false, bool HasNSW = false) {
431 SmallVector<const SCEV *, 2> Ops;
434 return getAddExpr(Ops, HasNUW, HasNSW);
436 const SCEV *getAddExpr(const SCEV *Op0, const SCEV *Op1,
438 bool HasNUW = false, bool HasNSW = false) {
439 SmallVector<const SCEV *, 3> Ops;
443 return getAddExpr(Ops, HasNUW, HasNSW);
445 const SCEV *getMulExpr(SmallVectorImpl<const SCEV *> &Ops,
446 bool HasNUW = false, bool HasNSW = false);
447 const SCEV *getMulExpr(const SCEV *LHS, const SCEV *RHS,
448 bool HasNUW = false, bool HasNSW = false) {
449 SmallVector<const SCEV *, 2> Ops;
452 return getMulExpr(Ops, HasNUW, HasNSW);
454 const SCEV *getUDivExpr(const SCEV *LHS, const SCEV *RHS);
455 const SCEV *getAddRecExpr(const SCEV *Start, const SCEV *Step,
457 bool HasNUW = false, bool HasNSW = false);
458 const SCEV *getAddRecExpr(SmallVectorImpl<const SCEV *> &Operands,
460 bool HasNUW = false, bool HasNSW = false);
461 const SCEV *getAddRecExpr(const SmallVectorImpl<const SCEV *> &Operands,
463 bool HasNUW = false, bool HasNSW = false) {
464 SmallVector<const SCEV *, 4> NewOp(Operands.begin(), Operands.end());
465 return getAddRecExpr(NewOp, L, HasNUW, HasNSW);
467 const SCEV *getSMaxExpr(const SCEV *LHS, const SCEV *RHS);
468 const SCEV *getSMaxExpr(SmallVectorImpl<const SCEV *> &Operands);
469 const SCEV *getUMaxExpr(const SCEV *LHS, const SCEV *RHS);
470 const SCEV *getUMaxExpr(SmallVectorImpl<const SCEV *> &Operands);
471 const SCEV *getSMinExpr(const SCEV *LHS, const SCEV *RHS);
472 const SCEV *getUMinExpr(const SCEV *LHS, const SCEV *RHS);
473 const SCEV *getUnknown(Value *V);
474 const SCEV *getCouldNotCompute();
476 /// getSizeOfExpr - Return an expression for sizeof on the given type.
478 const SCEV *getSizeOfExpr(const Type *AllocTy);
480 /// getAlignOfExpr - Return an expression for alignof on the given type.
482 const SCEV *getAlignOfExpr(const Type *AllocTy);
484 /// getOffsetOfExpr - Return an expression for offsetof on the given field.
486 const SCEV *getOffsetOfExpr(const StructType *STy, unsigned FieldNo);
488 /// getOffsetOfExpr - Return an expression for offsetof on the given field.
490 const SCEV *getOffsetOfExpr(const Type *CTy, Constant *FieldNo);
492 /// getNegativeSCEV - Return the SCEV object corresponding to -V.
494 const SCEV *getNegativeSCEV(const SCEV *V);
496 /// getNotSCEV - Return the SCEV object corresponding to ~V.
498 const SCEV *getNotSCEV(const SCEV *V);
500 /// getMinusSCEV - Return LHS-RHS.
502 const SCEV *getMinusSCEV(const SCEV *LHS,
505 /// getTruncateOrZeroExtend - Return a SCEV corresponding to a conversion
506 /// of the input value to the specified type. If the type must be
507 /// extended, it is zero extended.
508 const SCEV *getTruncateOrZeroExtend(const SCEV *V, const Type *Ty);
510 /// getTruncateOrSignExtend - Return a SCEV corresponding to a conversion
511 /// of the input value to the specified type. If the type must be
512 /// extended, it is sign extended.
513 const SCEV *getTruncateOrSignExtend(const SCEV *V, const Type *Ty);
515 /// getNoopOrZeroExtend - Return a SCEV corresponding to a conversion of
516 /// the input value to the specified type. If the type must be extended,
517 /// it is zero extended. The conversion must not be narrowing.
518 const SCEV *getNoopOrZeroExtend(const SCEV *V, const Type *Ty);
520 /// getNoopOrSignExtend - Return a SCEV corresponding to a conversion of
521 /// the input value to the specified type. If the type must be extended,
522 /// it is sign extended. The conversion must not be narrowing.
523 const SCEV *getNoopOrSignExtend(const SCEV *V, const Type *Ty);
525 /// getNoopOrAnyExtend - Return a SCEV corresponding to a conversion of
526 /// the input value to the specified type. If the type must be extended,
527 /// it is extended with unspecified bits. The conversion must not be
529 const SCEV *getNoopOrAnyExtend(const SCEV *V, const Type *Ty);
531 /// getTruncateOrNoop - Return a SCEV corresponding to a conversion of the
532 /// input value to the specified type. The conversion must not be
534 const SCEV *getTruncateOrNoop(const SCEV *V, const Type *Ty);
536 /// getIntegerSCEV - Given a SCEVable type, create a constant for the
537 /// specified signed integer value and return a SCEV for the constant.
538 const SCEV *getIntegerSCEV(int64_t Val, const Type *Ty);
540 /// getUMaxFromMismatchedTypes - Promote the operands to the wider of
541 /// the types using zero-extension, and then perform a umax operation
543 const SCEV *getUMaxFromMismatchedTypes(const SCEV *LHS,
546 /// getUMinFromMismatchedTypes - Promote the operands to the wider of
547 /// the types using zero-extension, and then perform a umin operation
549 const SCEV *getUMinFromMismatchedTypes(const SCEV *LHS,
552 /// getSCEVAtScope - Return a SCEV expression for the specified value
553 /// at the specified scope in the program. The L value specifies a loop
554 /// nest to evaluate the expression at, where null is the top-level or a
555 /// specified loop is immediately inside of the loop.
557 /// This method can be used to compute the exit value for a variable defined
558 /// in a loop by querying what the value will hold in the parent loop.
560 /// In the case that a relevant loop exit value cannot be computed, the
561 /// original value V is returned.
562 const SCEV *getSCEVAtScope(const SCEV *S, const Loop *L);
564 /// getSCEVAtScope - This is a convenience function which does
565 /// getSCEVAtScope(getSCEV(V), L).
566 const SCEV *getSCEVAtScope(Value *V, const Loop *L);
568 /// isLoopEntryGuardedByCond - Test whether entry to the loop is protected
569 /// by a conditional between LHS and RHS. This is used to help avoid max
570 /// expressions in loop trip counts, and to eliminate casts.
571 bool isLoopEntryGuardedByCond(const Loop *L, ICmpInst::Predicate Pred,
572 const SCEV *LHS, const SCEV *RHS);
574 /// isLoopBackedgeGuardedByCond - Test whether the backedge of the loop is
575 /// protected by a conditional between LHS and RHS. This is used to
576 /// to eliminate casts.
577 bool isLoopBackedgeGuardedByCond(const Loop *L, ICmpInst::Predicate Pred,
578 const SCEV *LHS, const SCEV *RHS);
580 /// getBackedgeTakenCount - If the specified loop has a predictable
581 /// backedge-taken count, return it, otherwise return a SCEVCouldNotCompute
582 /// object. The backedge-taken count is the number of times the loop header
583 /// will be branched to from within the loop. This is one less than the
584 /// trip count of the loop, since it doesn't count the first iteration,
585 /// when the header is branched to from outside the loop.
587 /// Note that it is not valid to call this method on a loop without a
588 /// loop-invariant backedge-taken count (see
589 /// hasLoopInvariantBackedgeTakenCount).
591 const SCEV *getBackedgeTakenCount(const Loop *L);
593 /// getMaxBackedgeTakenCount - Similar to getBackedgeTakenCount, except
594 /// return the least SCEV value that is known never to be less than the
595 /// actual backedge taken count.
596 const SCEV *getMaxBackedgeTakenCount(const Loop *L);
598 /// hasLoopInvariantBackedgeTakenCount - Return true if the specified loop
599 /// has an analyzable loop-invariant backedge-taken count.
600 bool hasLoopInvariantBackedgeTakenCount(const Loop *L);
602 /// forgetLoop - This method should be called by the client when it has
603 /// changed a loop in a way that may effect ScalarEvolution's ability to
604 /// compute a trip count, or if the loop is deleted.
605 void forgetLoop(const Loop *L);
607 /// forgetValue - This method should be called by the client when it has
608 /// changed a value in a way that may effect its value, or which may
609 /// disconnect it from a def-use chain linking it to a loop.
610 void forgetValue(Value *V);
612 /// GetMinTrailingZeros - Determine the minimum number of zero bits that S
613 /// is guaranteed to end in (at every loop iteration). It is, at the same
614 /// time, the minimum number of times S is divisible by 2. For example,
615 /// given {4,+,8} it returns 2. If S is guaranteed to be 0, it returns the
617 uint32_t GetMinTrailingZeros(const SCEV *S);
619 /// getUnsignedRange - Determine the unsigned range for a particular SCEV.
621 ConstantRange getUnsignedRange(const SCEV *S);
623 /// getSignedRange - Determine the signed range for a particular SCEV.
625 ConstantRange getSignedRange(const SCEV *S);
627 /// isKnownNegative - Test if the given expression is known to be negative.
629 bool isKnownNegative(const SCEV *S);
631 /// isKnownPositive - Test if the given expression is known to be positive.
633 bool isKnownPositive(const SCEV *S);
635 /// isKnownNonNegative - Test if the given expression is known to be
638 bool isKnownNonNegative(const SCEV *S);
640 /// isKnownNonPositive - Test if the given expression is known to be
643 bool isKnownNonPositive(const SCEV *S);
645 /// isKnownNonZero - Test if the given expression is known to be
648 bool isKnownNonZero(const SCEV *S);
650 /// isKnownPredicate - Test if the given expression is known to satisfy
651 /// the condition described by Pred, LHS, and RHS.
653 bool isKnownPredicate(ICmpInst::Predicate Pred,
654 const SCEV *LHS, const SCEV *RHS);
656 /// SimplifyICmpOperands - Simplify LHS and RHS in a comparison with
657 /// predicate Pred. Return true iff any changes were made. If the
658 /// operands are provably equal or inequal, LHS and RHS are set to
659 /// the same value and Pred is set to either ICMP_EQ or ICMP_NE.
661 bool SimplifyICmpOperands(ICmpInst::Predicate &Pred,
665 virtual bool runOnFunction(Function &F);
666 virtual void releaseMemory();
667 virtual void getAnalysisUsage(AnalysisUsage &AU) const;
668 virtual void print(raw_ostream &OS, const Module* = 0) const;
671 FoldingSet<SCEV> UniqueSCEVs;
672 BumpPtrAllocator SCEVAllocator;