Skip to content

Commit 6e3725d

Browse files
committed
[IndVars] Make pushIVUsers() a member function (NFC)
Make it easier to access additional state from it.
1 parent b8979c6 commit 6e3725d

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

llvm/lib/Transforms/Utils/SimplifyIndVar.cpp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ namespace {
8080
/// all simplifications to users of an IV.
8181
void simplifyUsers(PHINode *CurrIV, IVVisitor *V = nullptr);
8282

83+
void pushIVUsers(Instruction *Def,
84+
SmallPtrSet<Instruction *, 16> &Simplified,
85+
SmallVectorImpl<std::pair<Instruction *, Instruction *>>
86+
&SimpleIVUsers);
87+
8388
Value *foldIVUser(Instruction *UseInst, Instruction *IVOperand);
8489

8590
bool eliminateIdentitySCEV(Instruction *UseInst, Instruction *IVOperand);
@@ -839,11 +844,9 @@ bool SimplifyIndvar::strengthenRightShift(BinaryOperator *BO,
839844
}
840845

841846
/// Add all uses of Def to the current IV's worklist.
842-
static void pushIVUsers(
843-
Instruction *Def, Loop *L,
844-
SmallPtrSet<Instruction*,16> &Simplified,
845-
SmallVectorImpl< std::pair<Instruction*,Instruction*> > &SimpleIVUsers) {
846-
847+
void SimplifyIndvar::pushIVUsers(
848+
Instruction *Def, SmallPtrSet<Instruction *, 16> &Simplified,
849+
SmallVectorImpl<std::pair<Instruction *, Instruction *>> &SimpleIVUsers) {
847850
for (User *U : Def->users()) {
848851
Instruction *UI = cast<Instruction>(U);
849852

@@ -913,7 +916,7 @@ void SimplifyIndvar::simplifyUsers(PHINode *CurrIV, IVVisitor *V) {
913916
// Push users of the current LoopPhi. In rare cases, pushIVUsers may be
914917
// called multiple times for the same LoopPhi. This is the proper thing to
915918
// do for loop header phis that use each other.
916-
pushIVUsers(CurrIV, L, Simplified, SimpleIVUsers);
919+
pushIVUsers(CurrIV, Simplified, SimpleIVUsers);
917920

918921
while (!SimpleIVUsers.empty()) {
919922
std::pair<Instruction*, Instruction*> UseOper =
@@ -960,22 +963,22 @@ void SimplifyIndvar::simplifyUsers(PHINode *CurrIV, IVVisitor *V) {
960963
continue;
961964

962965
if (eliminateIVUser(UseInst, IVOperand)) {
963-
pushIVUsers(IVOperand, L, Simplified, SimpleIVUsers);
966+
pushIVUsers(IVOperand, Simplified, SimpleIVUsers);
964967
continue;
965968
}
966969

967970
if (BinaryOperator *BO = dyn_cast<BinaryOperator>(UseInst)) {
968971
if (strengthenBinaryOp(BO, IVOperand)) {
969972
// re-queue uses of the now modified binary operator and fall
970973
// through to the checks that remain.
971-
pushIVUsers(IVOperand, L, Simplified, SimpleIVUsers);
974+
pushIVUsers(IVOperand, Simplified, SimpleIVUsers);
972975
}
973976
}
974977

975978
// Try to use integer induction for FPToSI of float induction directly.
976979
if (replaceFloatIVWithIntegerIV(UseInst)) {
977980
// Re-queue the potentially new direct uses of IVOperand.
978-
pushIVUsers(IVOperand, L, Simplified, SimpleIVUsers);
981+
pushIVUsers(IVOperand, Simplified, SimpleIVUsers);
979982
continue;
980983
}
981984

@@ -985,7 +988,7 @@ void SimplifyIndvar::simplifyUsers(PHINode *CurrIV, IVVisitor *V) {
985988
continue;
986989
}
987990
if (isSimpleIVUser(UseInst, L, SE)) {
988-
pushIVUsers(UseInst, L, Simplified, SimpleIVUsers);
991+
pushIVUsers(UseInst, Simplified, SimpleIVUsers);
989992
}
990993
}
991994
}

0 commit comments

Comments
 (0)