Extend ScalarEvolution's multiple-exit support to compute exact
[oota-llvm.git] / include / llvm / Analysis / ScalarEvolution.h
1 //===- llvm/Analysis/ScalarEvolution.h - Scalar Evolution -------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // The ScalarEvolution class is an LLVM pass which can be used to analyze and
11 // catagorize 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.
15 //
16 // This analysis is primarily useful for induction variable substitution and
17 // strength reduction.
18 //
19 //===----------------------------------------------------------------------===//
20
21 #ifndef LLVM_ANALYSIS_SCALAREVOLUTION_H
22 #define LLVM_ANALYSIS_SCALAREVOLUTION_H
23
24 #include "llvm/Pass.h"
25 #include "llvm/Analysis/LoopInfo.h"
26 #include "llvm/Support/DataTypes.h"
27 #include "llvm/Support/ValueHandle.h"
28 #include "llvm/ADT/DenseMap.h"
29 #include <iosfwd>
30
31 namespace llvm {
32   class APInt;
33   class ConstantInt;
34   class Type;
35   class ScalarEvolution;
36   class TargetData;
37   class SCEVConstant;
38   class SCEVTruncateExpr;
39   class SCEVZeroExtendExpr;
40   class SCEVCommutativeExpr;
41   class SCEVUDivExpr;
42   class SCEVSignExtendExpr;
43   class SCEVAddRecExpr;
44   class SCEVUnknown;
45
46   /// SCEV - This class represents an analyzed expression in the program.  These
47   /// are reference-counted opaque objects that the client is not allowed to
48   /// do much with directly.
49   ///
50   class SCEV {
51     const unsigned SCEVType;      // The SCEV baseclass this node corresponds to
52
53     SCEV(const SCEV &);            // DO NOT IMPLEMENT
54     void operator=(const SCEV &);  // DO NOT IMPLEMENT
55   protected:
56     virtual ~SCEV();
57   public:
58     explicit SCEV(unsigned SCEVTy) : 
59       SCEVType(SCEVTy) {}
60
61     unsigned getSCEVType() const { return SCEVType; }
62
63     /// isLoopInvariant - Return true if the value of this SCEV is unchanging in
64     /// the specified loop.
65     virtual bool isLoopInvariant(const Loop *L) const = 0;
66
67     /// hasComputableLoopEvolution - Return true if this SCEV changes value in a
68     /// known way in the specified loop.  This property being true implies that
69     /// the value is variant in the loop AND that we can emit an expression to
70     /// compute the value of the expression at any particular loop iteration.
71     virtual bool hasComputableLoopEvolution(const Loop *L) const = 0;
72
73     /// getType - Return the LLVM type of this SCEV expression.
74     ///
75     virtual const Type *getType() const = 0;
76
77     /// isZero - Return true if the expression is a constant zero.
78     ///
79     bool isZero() const;
80
81     /// isOne - Return true if the expression is a constant one.
82     ///
83     bool isOne() const;
84
85     /// isAllOnesValue - Return true if the expression is a constant
86     /// all-ones value.
87     ///
88     bool isAllOnesValue() const;
89
90     /// replaceSymbolicValuesWithConcrete - If this SCEV internally references
91     /// the symbolic value "Sym", construct and return a new SCEV that produces
92     /// the same value, but which uses the concrete value Conc instead of the
93     /// symbolic value.  If this SCEV does not use the symbolic value, it
94     /// returns itself.
95     virtual const SCEV*
96     replaceSymbolicValuesWithConcrete(const SCEV* Sym,
97                                       const SCEV* Conc,
98                                       ScalarEvolution &SE) const = 0;
99
100     /// dominates - Return true if elements that makes up this SCEV dominates
101     /// the specified basic block.
102     virtual bool dominates(BasicBlock *BB, DominatorTree *DT) const = 0;
103
104     /// print - Print out the internal representation of this scalar to the
105     /// specified stream.  This should really only be used for debugging
106     /// purposes.
107     virtual void print(raw_ostream &OS) const = 0;
108     void print(std::ostream &OS) const;
109     void print(std::ostream *OS) const { if (OS) print(*OS); }
110
111     /// dump - This method is used for debugging.
112     ///
113     void dump() const;
114   };
115
116   inline raw_ostream &operator<<(raw_ostream &OS, const SCEV &S) {
117     S.print(OS);
118     return OS;
119   }
120
121   inline std::ostream &operator<<(std::ostream &OS, const SCEV &S) {
122     S.print(OS);
123     return OS;
124   }
125
126   /// SCEVCouldNotCompute - An object of this class is returned by queries that
127   /// could not be answered.  For example, if you ask for the number of
128   /// iterations of a linked-list traversal loop, you will get one of these.
129   /// None of the standard SCEV operations are valid on this class, it is just a
130   /// marker.
131   struct SCEVCouldNotCompute : public SCEV {
132     SCEVCouldNotCompute();
133
134     // None of these methods are valid for this object.
135     virtual bool isLoopInvariant(const Loop *L) const;
136     virtual const Type *getType() const;
137     virtual bool hasComputableLoopEvolution(const Loop *L) const;
138     virtual void print(raw_ostream &OS) const;
139     virtual const SCEV*
140     replaceSymbolicValuesWithConcrete(const SCEV* Sym,
141                                       const SCEV* Conc,
142                                       ScalarEvolution &SE) const;
143
144     virtual bool dominates(BasicBlock *BB, DominatorTree *DT) const {
145       return true;
146     }
147
148     /// Methods for support type inquiry through isa, cast, and dyn_cast:
149     static inline bool classof(const SCEVCouldNotCompute *S) { return true; }
150     static bool classof(const SCEV *S);
151   };
152
153   /// ScalarEvolution - This class is the main scalar evolution driver.  Because
154   /// client code (intentionally) can't do much with the SCEV objects directly,
155   /// they must ask this class for services.
156   ///
157   class ScalarEvolution : public FunctionPass {
158     /// SCEVCallbackVH - A CallbackVH to arrange for ScalarEvolution to be
159     /// notified whenever a Value is deleted.
160     class SCEVCallbackVH : public CallbackVH {
161       ScalarEvolution *SE;
162       virtual void deleted();
163       virtual void allUsesReplacedWith(Value *New);
164     public:
165       SCEVCallbackVH(Value *V, ScalarEvolution *SE = 0);
166     };
167
168     friend class SCEVCallbackVH;
169     friend class SCEVExpander;
170
171     /// F - The function we are analyzing.
172     ///
173     Function *F;
174
175     /// LI - The loop information for the function we are currently analyzing.
176     ///
177     LoopInfo *LI;
178
179     /// TD - The target data information for the target we are targetting.
180     ///
181     TargetData *TD;
182
183     /// CouldNotCompute - This SCEV is used to represent unknown trip
184     /// counts and things.
185     const SCEV* CouldNotCompute;
186
187     /// Scalars - This is a cache of the scalars we have analyzed so far.
188     ///
189     std::map<SCEVCallbackVH, const SCEV*> Scalars;
190
191     /// BackedgeTakenInfo - Information about the backedge-taken count
192     /// of a loop. This currently inclues an exact count and a maximum count.
193     ///
194     struct BackedgeTakenInfo {
195       /// Exact - An expression indicating the exact backedge-taken count of
196       /// the loop if it is known, or a SCEVCouldNotCompute otherwise.
197       const SCEV* Exact;
198
199       /// Exact - An expression indicating the least maximum backedge-taken
200       /// count of the loop that is known, or a SCEVCouldNotCompute.
201       const SCEV* Max;
202
203       /*implicit*/ BackedgeTakenInfo(const SCEV* exact) :
204         Exact(exact), Max(exact) {}
205
206       BackedgeTakenInfo(const SCEV* exact, const SCEV* max) :
207         Exact(exact), Max(max) {}
208
209       /// hasAnyInfo - Test whether this BackedgeTakenInfo contains any
210       /// computed information, or whether it's all SCEVCouldNotCompute
211       /// values.
212       bool hasAnyInfo() const {
213         return !isa<SCEVCouldNotCompute>(Exact) ||
214                !isa<SCEVCouldNotCompute>(Max);
215       }
216     };
217
218     /// BackedgeTakenCounts - Cache the backedge-taken count of the loops for
219     /// this function as they are computed.
220     std::map<const Loop*, BackedgeTakenInfo> BackedgeTakenCounts;
221
222     /// ConstantEvolutionLoopExitValue - This map contains entries for all of
223     /// the PHI instructions that we attempt to compute constant evolutions for.
224     /// This allows us to avoid potentially expensive recomputation of these
225     /// properties.  An instruction maps to null if we are unable to compute its
226     /// exit value.
227     std::map<PHINode*, Constant*> ConstantEvolutionLoopExitValue;
228
229     /// ValuesAtScopes - This map contains entries for all the instructions
230     /// that we attempt to compute getSCEVAtScope information for without
231     /// using SCEV techniques, which can be expensive.
232     std::map<Instruction *, std::map<const Loop *, Constant *> > ValuesAtScopes;
233
234     /// createSCEV - We know that there is no SCEV for the specified value.
235     /// Analyze the expression.
236     const SCEV* createSCEV(Value *V);
237
238     /// createNodeForPHI - Provide the special handling we need to analyze PHI
239     /// SCEVs.
240     const SCEV* createNodeForPHI(PHINode *PN);
241
242     /// createNodeForGEP - Provide the special handling we need to analyze GEP
243     /// SCEVs.
244     const SCEV* createNodeForGEP(User *GEP);
245
246     /// ReplaceSymbolicValueWithConcrete - This looks up the computed SCEV value
247     /// for the specified instruction and replaces any references to the
248     /// symbolic value SymName with the specified value.  This is used during
249     /// PHI resolution.
250     void ReplaceSymbolicValueWithConcrete(Instruction *I,
251                                           const SCEV* SymName,
252                                           const SCEV* NewVal);
253
254     /// getBECount - Subtract the end and start values and divide by the step,
255     /// rounding up, to get the number of times the backedge is executed. Return
256     /// CouldNotCompute if an intermediate computation overflows.
257     const SCEV* getBECount(const SCEV* Start,
258                           const SCEV* End,
259                           const SCEV* Step);
260
261     /// getBackedgeTakenInfo - Return the BackedgeTakenInfo for the given
262     /// loop, lazily computing new values if the loop hasn't been analyzed
263     /// yet.
264     const BackedgeTakenInfo &getBackedgeTakenInfo(const Loop *L);
265
266     /// ComputeBackedgeTakenCount - Compute the number of times the specified
267     /// loop will iterate.
268     BackedgeTakenInfo ComputeBackedgeTakenCount(const Loop *L);
269
270     /// ComputeBackedgeTakenCountFromExit - Compute the number of times the
271     /// backedge of the specified loop will execute if it exits via the
272     /// specified block.
273     BackedgeTakenInfo ComputeBackedgeTakenCountFromExit(const Loop *L,
274                                                       BasicBlock *ExitingBlock);
275
276     /// ComputeBackedgeTakenCountFromExitCond - Compute the number of times the
277     /// backedge of the specified loop will execute if its exit condition
278     /// were a conditional branch of ExitCond, TBB, and FBB.
279     BackedgeTakenInfo
280       ComputeBackedgeTakenCountFromExitCond(const Loop *L,
281                                             Value *ExitCond,
282                                             BasicBlock *TBB,
283                                             BasicBlock *FBB);
284
285     /// ComputeBackedgeTakenCountFromExitCondICmp - Compute the number of
286     /// times the backedge of the specified loop will execute if its exit
287     /// condition were a conditional branch of the ICmpInst ExitCond, TBB,
288     /// and FBB.
289     BackedgeTakenInfo
290       ComputeBackedgeTakenCountFromExitCondICmp(const Loop *L,
291                                                 ICmpInst *ExitCond,
292                                                 BasicBlock *TBB,
293                                                 BasicBlock *FBB);
294
295     /// ComputeLoadConstantCompareBackedgeTakenCount - Given an exit condition
296     /// of 'icmp op load X, cst', try to see if we can compute the trip count.
297     const SCEV*
298       ComputeLoadConstantCompareBackedgeTakenCount(LoadInst *LI,
299                                                    Constant *RHS,
300                                                    const Loop *L,
301                                                    ICmpInst::Predicate p);
302
303     /// ComputeBackedgeTakenCountExhaustively - If the trip is known to execute
304     /// a constant number of times (the condition evolves only from constants),
305     /// try to evaluate a few iterations of the loop until we get the exit
306     /// condition gets a value of ExitWhen (true or false).  If we cannot
307     /// evaluate the trip count of the loop, return CouldNotCompute.
308     const SCEV* ComputeBackedgeTakenCountExhaustively(const Loop *L, Value *Cond,
309                                                      bool ExitWhen);
310
311     /// HowFarToZero - Return the number of times a backedge comparing the
312     /// specified value to zero will execute.  If not computable, return
313     /// CouldNotCompute.
314     const SCEV* HowFarToZero(const SCEV *V, const Loop *L);
315
316     /// HowFarToNonZero - Return the number of times a backedge checking the
317     /// specified value for nonzero will execute.  If not computable, return
318     /// CouldNotCompute.
319     const SCEV* HowFarToNonZero(const SCEV *V, const Loop *L);
320
321     /// HowManyLessThans - Return the number of times a backedge containing the
322     /// specified less-than comparison will execute.  If not computable, return
323     /// CouldNotCompute. isSigned specifies whether the less-than is signed.
324     BackedgeTakenInfo HowManyLessThans(const SCEV *LHS, const SCEV *RHS,
325                                        const Loop *L, bool isSigned);
326
327     /// getLoopPredecessor - If the given loop's header has exactly one unique
328     /// predecessor outside the loop, return it. Otherwise return null.
329     BasicBlock *getLoopPredecessor(const Loop *L);
330
331     /// getPredecessorWithUniqueSuccessorForBB - Return a predecessor of BB
332     /// (which may not be an immediate predecessor) which has exactly one
333     /// successor from which BB is reachable, or null if no such block is
334     /// found.
335     BasicBlock* getPredecessorWithUniqueSuccessorForBB(BasicBlock *BB);
336
337     /// isNecessaryCond - Test whether the given CondValue value is a condition
338     /// which is at least as strict as the one described by Pred, LHS, and RHS.
339     bool isNecessaryCond(Value *Cond, ICmpInst::Predicate Pred,
340                          const SCEV *LHS, const SCEV *RHS,
341                          bool Inverse);
342
343     /// getConstantEvolutionLoopExitValue - If we know that the specified Phi is
344     /// in the header of its containing loop, we know the loop executes a
345     /// constant number of times, and the PHI node is just a recurrence
346     /// involving constants, fold it.
347     Constant *getConstantEvolutionLoopExitValue(PHINode *PN, const APInt& BEs,
348                                                 const Loop *L);
349
350     /// forgetLoopPHIs - Delete the memoized SCEVs associated with the
351     /// PHI nodes in the given loop. This is used when the trip count of
352     /// the loop may have changed.
353     void forgetLoopPHIs(const Loop *L);
354
355   public:
356     static char ID; // Pass identification, replacement for typeid
357     ScalarEvolution();
358
359     /// isSCEVable - Test if values of the given type are analyzable within
360     /// the SCEV framework. This primarily includes integer types, and it
361     /// can optionally include pointer types if the ScalarEvolution class
362     /// has access to target-specific information.
363     bool isSCEVable(const Type *Ty) const;
364
365     /// getTypeSizeInBits - Return the size in bits of the specified type,
366     /// for which isSCEVable must return true.
367     uint64_t getTypeSizeInBits(const Type *Ty) const;
368
369     /// getEffectiveSCEVType - Return a type with the same bitwidth as
370     /// the given type and which represents how SCEV will treat the given
371     /// type, for which isSCEVable must return true. For pointer types,
372     /// this is the pointer-sized integer type.
373     const Type *getEffectiveSCEVType(const Type *Ty) const;
374
375     /// getSCEV - Return a SCEV expression handle for the full generality of the
376     /// specified expression.
377     const SCEV* getSCEV(Value *V);
378
379     const SCEV* getConstant(ConstantInt *V);
380     const SCEV* getConstant(const APInt& Val);
381     const SCEV* getConstant(const Type *Ty, uint64_t V, bool isSigned = false);
382     const SCEV* getTruncateExpr(const SCEV* Op, const Type *Ty);
383     const SCEV* getZeroExtendExpr(const SCEV* Op, const Type *Ty);
384     const SCEV* getSignExtendExpr(const SCEV* Op, const Type *Ty);
385     const SCEV* getAnyExtendExpr(const SCEV* Op, const Type *Ty);
386     const SCEV* getAddExpr(SmallVectorImpl<const SCEV*> &Ops);
387     const SCEV* getAddExpr(const SCEV* LHS, const SCEV* RHS) {
388       SmallVector<const SCEV*, 2> Ops;
389       Ops.push_back(LHS);
390       Ops.push_back(RHS);
391       return getAddExpr(Ops);
392     }
393     const SCEV* getAddExpr(const SCEV* Op0, const SCEV* Op1,
394                           const SCEV* Op2) {
395       SmallVector<const SCEV*, 3> Ops;
396       Ops.push_back(Op0);
397       Ops.push_back(Op1);
398       Ops.push_back(Op2);
399       return getAddExpr(Ops);
400     }
401     const SCEV* getMulExpr(SmallVectorImpl<const SCEV*> &Ops);
402     const SCEV* getMulExpr(const SCEV* LHS, const SCEV* RHS) {
403       SmallVector<const SCEV*, 2> Ops;
404       Ops.push_back(LHS);
405       Ops.push_back(RHS);
406       return getMulExpr(Ops);
407     }
408     const SCEV* getUDivExpr(const SCEV* LHS, const SCEV* RHS);
409     const SCEV* getAddRecExpr(const SCEV* Start, const SCEV* Step,
410                              const Loop *L);
411     const SCEV* getAddRecExpr(SmallVectorImpl<const SCEV*> &Operands,
412                              const Loop *L);
413     const SCEV* getAddRecExpr(const SmallVectorImpl<const SCEV*> &Operands,
414                              const Loop *L) {
415       SmallVector<const SCEV*, 4> NewOp(Operands.begin(), Operands.end());
416       return getAddRecExpr(NewOp, L);
417     }
418     const SCEV* getSMaxExpr(const SCEV* LHS, const SCEV* RHS);
419     const SCEV* getSMaxExpr(SmallVectorImpl<const SCEV*> &Operands);
420     const SCEV* getUMaxExpr(const SCEV* LHS, const SCEV* RHS);
421     const SCEV* getUMaxExpr(SmallVectorImpl<const SCEV*> &Operands);
422     const SCEV* getSMinExpr(const SCEV* LHS, const SCEV* RHS);
423     const SCEV* getUMinExpr(const SCEV* LHS, const SCEV* RHS);
424     const SCEV* getUnknown(Value *V);
425     const SCEV* getCouldNotCompute();
426
427     /// getNegativeSCEV - Return the SCEV object corresponding to -V.
428     ///
429     const SCEV* getNegativeSCEV(const SCEV* V);
430
431     /// getNotSCEV - Return the SCEV object corresponding to ~V.
432     ///
433     const SCEV* getNotSCEV(const SCEV* V);
434
435     /// getMinusSCEV - Return LHS-RHS.
436     ///
437     const SCEV* getMinusSCEV(const SCEV* LHS,
438                             const SCEV* RHS);
439
440     /// getTruncateOrZeroExtend - Return a SCEV corresponding to a conversion
441     /// of the input value to the specified type.  If the type must be
442     /// extended, it is zero extended.
443     const SCEV* getTruncateOrZeroExtend(const SCEV* V, const Type *Ty);
444
445     /// getTruncateOrSignExtend - Return a SCEV corresponding to a conversion
446     /// of the input value to the specified type.  If the type must be
447     /// extended, it is sign extended.
448     const SCEV* getTruncateOrSignExtend(const SCEV* V, const Type *Ty);
449
450     /// getNoopOrZeroExtend - Return a SCEV corresponding to a conversion of
451     /// the input value to the specified type.  If the type must be extended,
452     /// it is zero extended.  The conversion must not be narrowing.
453     const SCEV* getNoopOrZeroExtend(const SCEV* V, const Type *Ty);
454
455     /// getNoopOrSignExtend - Return a SCEV corresponding to a conversion of
456     /// the input value to the specified type.  If the type must be extended,
457     /// it is sign extended.  The conversion must not be narrowing.
458     const SCEV* getNoopOrSignExtend(const SCEV* V, const Type *Ty);
459
460     /// getNoopOrAnyExtend - Return a SCEV corresponding to a conversion of
461     /// the input value to the specified type. If the type must be extended,
462     /// it is extended with unspecified bits. The conversion must not be
463     /// narrowing.
464     const SCEV* getNoopOrAnyExtend(const SCEV* V, const Type *Ty);
465
466     /// getTruncateOrNoop - Return a SCEV corresponding to a conversion of the
467     /// input value to the specified type.  The conversion must not be
468     /// widening.
469     const SCEV* getTruncateOrNoop(const SCEV* V, const Type *Ty);
470
471     /// getIntegerSCEV - Given a SCEVable type, create a constant for the
472     /// specified signed integer value and return a SCEV for the constant.
473     const SCEV* getIntegerSCEV(int Val, const Type *Ty);
474
475     /// getUMaxFromMismatchedTypes - Promote the operands to the wider of
476     /// the types using zero-extension, and then perform a umax operation
477     /// with them.
478     const SCEV* getUMaxFromMismatchedTypes(const SCEV* LHS,
479                                           const SCEV* RHS);
480
481     /// getUMinFromMismatchedTypes - Promote the operands to the wider of
482     /// the types using zero-extension, and then perform a umin operation
483     /// with them.
484     const SCEV* getUMinFromMismatchedTypes(const SCEV* LHS,
485                                            const SCEV* RHS);
486
487     /// hasSCEV - Return true if the SCEV for this value has already been
488     /// computed.
489     bool hasSCEV(Value *V) const;
490
491     /// setSCEV - Insert the specified SCEV into the map of current SCEVs for
492     /// the specified value.
493     void setSCEV(Value *V, const SCEV* H);
494
495     /// getSCEVAtScope - Return a SCEV expression handle for the specified value
496     /// at the specified scope in the program.  The L value specifies a loop
497     /// nest to evaluate the expression at, where null is the top-level or a
498     /// specified loop is immediately inside of the loop.
499     ///
500     /// This method can be used to compute the exit value for a variable defined
501     /// in a loop by querying what the value will hold in the parent loop.
502     ///
503     /// In the case that a relevant loop exit value cannot be computed, the
504     /// original value V is returned.
505     const SCEV* getSCEVAtScope(const SCEV *S, const Loop *L);
506
507     /// getSCEVAtScope - This is a convenience function which does
508     /// getSCEVAtScope(getSCEV(V), L).
509     const SCEV* getSCEVAtScope(Value *V, const Loop *L);
510
511     /// isLoopGuardedByCond - Test whether entry to the loop is protected by
512     /// a conditional between LHS and RHS.  This is used to help avoid max
513     /// expressions in loop trip counts.
514     bool isLoopGuardedByCond(const Loop *L, ICmpInst::Predicate Pred,
515                              const SCEV *LHS, const SCEV *RHS);
516
517     /// getBackedgeTakenCount - If the specified loop has a predictable
518     /// backedge-taken count, return it, otherwise return a SCEVCouldNotCompute
519     /// object. The backedge-taken count is the number of times the loop header
520     /// will be branched to from within the loop. This is one less than the
521     /// trip count of the loop, since it doesn't count the first iteration,
522     /// when the header is branched to from outside the loop.
523     ///
524     /// Note that it is not valid to call this method on a loop without a
525     /// loop-invariant backedge-taken count (see
526     /// hasLoopInvariantBackedgeTakenCount).
527     ///
528     const SCEV* getBackedgeTakenCount(const Loop *L);
529
530     /// getMaxBackedgeTakenCount - Similar to getBackedgeTakenCount, except
531     /// return the least SCEV value that is known never to be less than the
532     /// actual backedge taken count.
533     const SCEV* getMaxBackedgeTakenCount(const Loop *L);
534
535     /// hasLoopInvariantBackedgeTakenCount - Return true if the specified loop
536     /// has an analyzable loop-invariant backedge-taken count.
537     bool hasLoopInvariantBackedgeTakenCount(const Loop *L);
538
539     /// forgetLoopBackedgeTakenCount - This method should be called by the
540     /// client when it has changed a loop in a way that may effect
541     /// ScalarEvolution's ability to compute a trip count, or if the loop
542     /// is deleted.
543     void forgetLoopBackedgeTakenCount(const Loop *L);
544
545     /// GetMinTrailingZeros - Determine the minimum number of zero bits that S is
546     /// guaranteed to end in (at every loop iteration).  It is, at the same time,
547     /// the minimum number of times S is divisible by 2.  For example, given {4,+,8}
548     /// it returns 2.  If S is guaranteed to be 0, it returns the bitwidth of S.
549     uint32_t GetMinTrailingZeros(const SCEV* S);
550
551     /// GetMinLeadingZeros - Determine the minimum number of zero bits that S is
552     /// guaranteed to begin with (at every loop iteration).
553     uint32_t GetMinLeadingZeros(const SCEV* S);
554
555     /// GetMinSignBits - Determine the minimum number of sign bits that S is
556     /// guaranteed to begin with.
557     uint32_t GetMinSignBits(const SCEV* S);
558
559     virtual bool runOnFunction(Function &F);
560     virtual void releaseMemory();
561     virtual void getAnalysisUsage(AnalysisUsage &AU) const;
562     void print(raw_ostream &OS, const Module* = 0) const;
563     virtual void print(std::ostream &OS, const Module* = 0) const;
564     void print(std::ostream *OS, const Module* M = 0) const {
565       if (OS) print(*OS, M);
566     }
567     
568   private:
569     // Uniquing tables.
570     std::map<ConstantInt*, SCEVConstant*> SCEVConstants;
571     std::map<std::pair<const SCEV*, const Type*>,
572              SCEVTruncateExpr*> SCEVTruncates;
573     std::map<std::pair<const SCEV*, const Type*>,
574              SCEVZeroExtendExpr*> SCEVZeroExtends;
575     std::map<std::pair<unsigned, std::vector<const SCEV*> >,
576              SCEVCommutativeExpr*> SCEVCommExprs;
577     std::map<std::pair<const SCEV*, const SCEV*>,
578              SCEVUDivExpr*> SCEVUDivs;
579     std::map<std::pair<const SCEV*, const Type*>,
580              SCEVSignExtendExpr*> SCEVSignExtends;
581     std::map<std::pair<const Loop *, std::vector<const SCEV*> >,
582              SCEVAddRecExpr*> SCEVAddRecExprs;
583     std::map<Value*, SCEVUnknown*> SCEVUnknowns;
584   };
585 }
586
587 #endif