LLVM  8.0.1
SimplifyIndVar.h
Go to the documentation of this file.
1 //===-- llvm/Transforms/Utils/SimplifyIndVar.h - Indvar Utils ---*- 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 // This file defines in interface for induction variable simplification. It does
11 // not define any actual pass or policy, but provides a single function to
12 // simplify a loop's induction variables based on ScalarEvolution.
13 //
14 //===----------------------------------------------------------------------===//
15 
16 #ifndef LLVM_TRANSFORMS_UTILS_SIMPLIFYINDVAR_H
17 #define LLVM_TRANSFORMS_UTILS_SIMPLIFYINDVAR_H
18 
19 #include "llvm/IR/ValueHandle.h"
20 
21 namespace llvm {
22 
23 class CastInst;
24 class DominatorTree;
25 class Loop;
26 class LoopInfo;
27 class PHINode;
28 class ScalarEvolution;
29 class SCEVExpander;
30 
31 /// Interface for visiting interesting IV users that are recognized but not
32 /// simplified by this utility.
33 class IVVisitor {
34 protected:
35  const DominatorTree *DT = nullptr;
36 
37  virtual void anchor();
38 
39 public:
40  IVVisitor() = default;
41  virtual ~IVVisitor() = default;
42 
43  const DominatorTree *getDomTree() const { return DT; }
44  virtual void visitCast(CastInst *Cast) = 0;
45 };
46 
47 /// simplifyUsersOfIV - Simplify instructions that use this induction variable
48 /// by using ScalarEvolution to analyze the IV's recurrence.
51  SCEVExpander &Rewriter, IVVisitor *V = nullptr);
52 
53 /// SimplifyLoopIVs - Simplify users of induction variables within this
54 /// loop. This does not actually change or add IVs.
57 
58 } // end namespace llvm
59 
60 #endif // LLVM_TRANSFORMS_UTILS_SIMPLIFYINDVAR_H
This class represents lattice values for constants.
Definition: AllocatorList.h:24
The main scalar evolution driver.
virtual ~IVVisitor()=default
virtual void anchor()
Interface for visiting interesting IV users that are recognized but not simplified by this utility...
This is the base class for all instructions that perform data casts.
Definition: InstrTypes.h:353
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:42
IVVisitor()=default
const DominatorTree * DT
bool simplifyLoopIVs(Loop *L, ScalarEvolution *SE, DominatorTree *DT, LoopInfo *LI, SmallVectorImpl< WeakTrackingVH > &Dead)
SimplifyLoopIVs - Simplify users of induction variables within this loop.
const DominatorTree * getDomTree() const
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
Definition: Dominators.h:145
This class uses information about analyze scalars to rewrite expressions in canonical form...
Virtual Register Rewriter
Definition: VirtRegMap.cpp:222
virtual void visitCast(CastInst *Cast)=0
Represents a single loop in the control flow graph.
Definition: LoopInfo.h:465
bool simplifyUsersOfIV(PHINode *CurrIV, ScalarEvolution *SE, DominatorTree *DT, LoopInfo *LI, SmallVectorImpl< WeakTrackingVH > &Dead, SCEVExpander &Rewriter, IVVisitor *V=nullptr)
simplifyUsersOfIV - Simplify instructions that use this induction variable by using ScalarEvolution t...