Skip to content

Commit 890632e

Browse files
committed
[InstCombine] Use matchSimpleRecurrence
1 parent d2a5040 commit 890632e

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1868,13 +1868,13 @@ Instruction *InstCombinerImpl::visitAdd(BinaryOperator &I) {
18681868
if (Instruction *Res = foldBinOpOfSelectAndCastOfSelectCondition(I))
18691869
return Res;
18701870

1871-
// Re-enqueue add instruction with PHI operands if we infer new nuw/nsw flags.
1872-
if (Changed &&
1873-
(isa<PHINode>(I.getOperand(0)) || isa<PHINode>(I.getOperand(1)))) {
1874-
for (User *U : I.users()) {
1875-
if (auto *PHI = dyn_cast<PHINode>(U))
1876-
Worklist.pushUsersToWorkList(*PHI);
1877-
}
1871+
// Re-enqueue the induction variable of add recurrence if we infer new
1872+
// nuw/nsw flags.
1873+
if (Changed) {
1874+
PHINode *PHI;
1875+
Value *Start, *Step;
1876+
if (matchSimpleRecurrence(&I, PHI, Start, Step))
1877+
Worklist.pushUsersToWorkList(*PHI);
18781878
}
18791879

18801880
return Changed ? &I : nullptr;

0 commit comments

Comments
 (0)