File indexing completed on 2026-05-10 08:44:44
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef LLVM_TRANSFORMS_UTILS_SIMPLIFYINDVAR_H
0016 #define LLVM_TRANSFORMS_UTILS_SIMPLIFYINDVAR_H
0017
0018 #include <utility>
0019
0020 namespace llvm {
0021
0022 class Type;
0023 class WeakTrackingVH;
0024 template <typename T> class SmallVectorImpl;
0025 class CastInst;
0026 class DominatorTree;
0027 class Loop;
0028 class LoopInfo;
0029 class PHINode;
0030 class ScalarEvolution;
0031 class SCEVExpander;
0032 class TargetTransformInfo;
0033
0034
0035
0036 class IVVisitor {
0037 protected:
0038 const DominatorTree *DT = nullptr;
0039
0040 virtual void anchor();
0041
0042 public:
0043 IVVisitor() = default;
0044 virtual ~IVVisitor() = default;
0045
0046 const DominatorTree *getDomTree() const { return DT; }
0047 virtual void visitCast(CastInst *Cast) = 0;
0048 };
0049
0050
0051
0052
0053
0054
0055 std::pair<bool, bool> simplifyUsersOfIV(PHINode *CurrIV, ScalarEvolution *SE,
0056 DominatorTree *DT, LoopInfo *LI,
0057 const TargetTransformInfo *TTI,
0058 SmallVectorImpl<WeakTrackingVH> &Dead,
0059 SCEVExpander &Rewriter,
0060 IVVisitor *V = nullptr);
0061
0062
0063
0064 bool simplifyLoopIVs(Loop *L, ScalarEvolution *SE, DominatorTree *DT,
0065 LoopInfo *LI, const TargetTransformInfo *TTI,
0066 SmallVectorImpl<WeakTrackingVH> &Dead);
0067
0068
0069
0070
0071 struct WideIVInfo {
0072 PHINode *NarrowIV = nullptr;
0073
0074
0075 Type *WidestNativeType = nullptr;
0076
0077
0078 bool IsSigned = false;
0079 };
0080
0081
0082
0083 PHINode *createWideIV(const WideIVInfo &WI,
0084 LoopInfo *LI, ScalarEvolution *SE, SCEVExpander &Rewriter,
0085 DominatorTree *DT, SmallVectorImpl<WeakTrackingVH> &DeadInsts,
0086 unsigned &NumElimExt, unsigned &NumWidened,
0087 bool HasGuards, bool UsePostIncrementRanges);
0088
0089 }
0090
0091 #endif