1 //===-- llvm/Transforms/Utils/SimplifyIndVar.h - Indvar Utils ---*- 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 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.
14 //===----------------------------------------------------------------------===//
16 #ifndef LLVM_TRANSFORMS_UTILS_SIMPLIFYINDVAR_H
17 #define LLVM_TRANSFORMS_UTILS_SIMPLIFYINDVAR_H
19 #include "llvm/IR/ValueHandle.h"
29 class ScalarEvolution;
31 /// Interface for visiting interesting IV users that are recognized but not
32 /// simplified by this utility.
35 const DominatorTree *DT;
37 virtual void anchor();
40 IVVisitor() : DT(nullptr) {}
41 virtual ~IVVisitor() {}
43 const DominatorTree *getDomTree() const { return DT; }
44 virtual void visitCast(CastInst *Cast) = 0;
47 /// simplifyUsersOfIV - Simplify instructions that use this induction variable
48 /// by using ScalarEvolution to analyze the IV's recurrence.
49 bool simplifyUsersOfIV(PHINode *CurrIV, ScalarEvolution *SE, DominatorTree *DT,
50 LoopInfo *LI, SmallVectorImpl<WeakVH> &Dead,
51 IVVisitor *V = nullptr);
53 /// SimplifyLoopIVs - Simplify users of induction variables within this
54 /// loop. This does not actually change or add IVs.
55 bool simplifyLoopIVs(Loop *L, ScalarEvolution *SE, DominatorTree *DT,
56 LoopInfo *LI, SmallVectorImpl<WeakVH> &Dead);