diff options
author | Nikita Popov <npopov@redhat.com> | 2024-06-24 14:36:10 +0200 |
---|---|---|
committer | Nikita Popov <npopov@redhat.com> | 2024-06-24 14:39:05 +0200 |
commit | 6e3725d7f290d0180e8b5cfe073d0cc4c9bbafd0 (patch) | |
tree | 941d904f836606752fcf353ed01dadc0681d014f /llvm/lib/Transforms/Utils/SimplifyIndVar.cpp | |
parent | b8979c6b13e9d4cb5051dd6f8ca772a20b14b428 (diff) | |
download | llvm-6e3725d7f290d0180e8b5cfe073d0cc4c9bbafd0.zip llvm-6e3725d7f290d0180e8b5cfe073d0cc4c9bbafd0.tar.gz llvm-6e3725d7f290d0180e8b5cfe073d0cc4c9bbafd0.tar.bz2 |
[IndVars] Make pushIVUsers() a member function (NFC)
Make it easier to access additional state from it.
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyIndVar.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyIndVar.cpp | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp index 912c02c..74af0ef 100644 --- a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp @@ -80,6 +80,11 @@ namespace { /// all simplifications to users of an IV. void simplifyUsers(PHINode *CurrIV, IVVisitor *V = nullptr); + void pushIVUsers(Instruction *Def, + SmallPtrSet<Instruction *, 16> &Simplified, + SmallVectorImpl<std::pair<Instruction *, Instruction *>> + &SimpleIVUsers); + Value *foldIVUser(Instruction *UseInst, Instruction *IVOperand); bool eliminateIdentitySCEV(Instruction *UseInst, Instruction *IVOperand); @@ -839,11 +844,9 @@ bool SimplifyIndvar::strengthenRightShift(BinaryOperator *BO, } /// Add all uses of Def to the current IV's worklist. -static void pushIVUsers( - Instruction *Def, Loop *L, - SmallPtrSet<Instruction*,16> &Simplified, - SmallVectorImpl< std::pair<Instruction*,Instruction*> > &SimpleIVUsers) { - +void SimplifyIndvar::pushIVUsers( + Instruction *Def, SmallPtrSet<Instruction *, 16> &Simplified, + SmallVectorImpl<std::pair<Instruction *, Instruction *>> &SimpleIVUsers) { for (User *U : Def->users()) { Instruction *UI = cast<Instruction>(U); @@ -913,7 +916,7 @@ void SimplifyIndvar::simplifyUsers(PHINode *CurrIV, IVVisitor *V) { // Push users of the current LoopPhi. In rare cases, pushIVUsers may be // called multiple times for the same LoopPhi. This is the proper thing to // do for loop header phis that use each other. - pushIVUsers(CurrIV, L, Simplified, SimpleIVUsers); + pushIVUsers(CurrIV, Simplified, SimpleIVUsers); while (!SimpleIVUsers.empty()) { std::pair<Instruction*, Instruction*> UseOper = @@ -960,7 +963,7 @@ void SimplifyIndvar::simplifyUsers(PHINode *CurrIV, IVVisitor *V) { continue; if (eliminateIVUser(UseInst, IVOperand)) { - pushIVUsers(IVOperand, L, Simplified, SimpleIVUsers); + pushIVUsers(IVOperand, Simplified, SimpleIVUsers); continue; } @@ -968,14 +971,14 @@ void SimplifyIndvar::simplifyUsers(PHINode *CurrIV, IVVisitor *V) { if (strengthenBinaryOp(BO, IVOperand)) { // re-queue uses of the now modified binary operator and fall // through to the checks that remain. - pushIVUsers(IVOperand, L, Simplified, SimpleIVUsers); + pushIVUsers(IVOperand, Simplified, SimpleIVUsers); } } // Try to use integer induction for FPToSI of float induction directly. if (replaceFloatIVWithIntegerIV(UseInst)) { // Re-queue the potentially new direct uses of IVOperand. - pushIVUsers(IVOperand, L, Simplified, SimpleIVUsers); + pushIVUsers(IVOperand, Simplified, SimpleIVUsers); continue; } @@ -985,7 +988,7 @@ void SimplifyIndvar::simplifyUsers(PHINode *CurrIV, IVVisitor *V) { continue; } if (isSimpleIVUser(UseInst, L, SE)) { - pushIVUsers(UseInst, L, Simplified, SimpleIVUsers); + pushIVUsers(UseInst, Simplified, SimpleIVUsers); } } } |