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/Support/CommandLine.h"
20 #include "llvm/Support/ValueHandle.h"
24 extern cl::opt<bool> DisableIVRewrite;
31 class ScalarEvolution;
33 /// Interface for visiting interesting IV users that are recognized but not
34 /// simplified by this utility.
36 virtual void anchor();
38 virtual ~IVVisitor() {}
39 virtual void visitCast(CastInst *Cast) = 0;
42 /// simplifyUsersOfIV - Simplify instructions that use this induction variable
43 /// by using ScalarEvolution to analyze the IV's recurrence.
44 bool simplifyUsersOfIV(PHINode *CurrIV, ScalarEvolution *SE, LPPassManager *LPM,
45 SmallVectorImpl<WeakVH> &Dead, IVVisitor *V = NULL);
47 /// SimplifyLoopIVs - Simplify users of induction variables within this
48 /// loop. This does not actually change or add IVs.
49 bool simplifyLoopIVs(Loop *L, ScalarEvolution *SE, LPPassManager *LPM,
50 SmallVectorImpl<WeakVH> &Dead);
52 /// simplifyIVUsers - Simplify instructions recorded by the IVUsers pass.
53 /// This is a legacy implementation to reproduce the behavior of the
54 /// IndVarSimplify pass prior to DisableIVRewrite.
55 bool simplifyIVUsers(IVUsers *IU, ScalarEvolution *SE, LPPassManager *LPM,
56 SmallVectorImpl<WeakVH> &Dead);