LLVM  11.0.0git
SimplifyIndVar.h
Go to the documentation of this file.
1 //===-- llvm/Transforms/Utils/SimplifyIndVar.h - Indvar Utils ---*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines in interface for induction variable simplification. It does
10 // not define any actual pass or policy, but provides a single function to
11 // simplify a loop's induction variables based on ScalarEvolution.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_TRANSFORMS_UTILS_SIMPLIFYINDVAR_H
16 #define LLVM_TRANSFORMS_UTILS_SIMPLIFYINDVAR_H
17 
18 #include "llvm/IR/ValueHandle.h"
19 
20 namespace llvm {
21 
22 class CastInst;
23 class DominatorTree;
24 class Loop;
25 class LoopInfo;
26 class PHINode;
27 class ScalarEvolution;
28 class SCEVExpander;
29 class TargetTransformInfo;
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.
50  LoopInfo *LI, const TargetTransformInfo *TTI,
52  SCEVExpander &Rewriter, IVVisitor *V = nullptr);
53 
54 /// SimplifyLoopIVs - Simplify users of induction variables within this
55 /// loop. This does not actually change or add IVs.
57  LoopInfo *LI, const TargetTransformInfo *TTI,
59 
60 } // end namespace llvm
61 
62 #endif // LLVM_TRANSFORMS_UTILS_SIMPLIFYINDVAR_H
This class represents lattice values for constants.
Definition: AllocatorList.h:23
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:432
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:43
IVVisitor()=default
const DominatorTree * DT
const DominatorTree * getDomTree() const
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
Definition: Dominators.h:144
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
bool simplifyUsersOfIV(PHINode *CurrIV, ScalarEvolution *SE, DominatorTree *DT, LoopInfo *LI, const TargetTransformInfo *TTI, SmallVectorImpl< WeakTrackingVH > &Dead, SCEVExpander &Rewriter, IVVisitor *V=nullptr)
simplifyUsersOfIV - Simplify instructions that use this induction variable by using ScalarEvolution t...
This class uses information about analyze scalars to rewrite expressions in canonical form...
Virtual Register Rewriter
Definition: VirtRegMap.cpp:220
virtual void visitCast(CastInst *Cast)=0
Represents a single loop in the control flow graph.
Definition: LoopInfo.h:516
bool simplifyLoopIVs(Loop *L, ScalarEvolution *SE, DominatorTree *DT, LoopInfo *LI, const TargetTransformInfo *TTI, SmallVectorImpl< WeakTrackingVH > &Dead)
SimplifyLoopIVs - Simplify users of induction variables within this loop.