Skip to content

Commit 672e8bf

Browse files
committed
[InstCombine] Fix worklist management in foldXorOfICmps()
Because this code does not use the IC-aware replaceInstUsesWith() helper, we need to manually push users to the worklist. This is NFC-ish, in that it may only change worklist order.
1 parent 337b671 commit 672e8bf

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2889,6 +2889,7 @@ Value *InstCombiner::foldXorOfICmps(ICmpInst *LHS, ICmpInst *RHS,
28892889
Builder.SetInsertPoint(Y->getParent(), ++(Y->getIterator()));
28902890
Value *NotY = Builder.CreateNot(Y, Y->getName() + ".not");
28912891
// Replace all uses of Y (excluding the one in NotY!) with NotY.
2892+
Worklist.pushUsersToWorkList(*Y);
28922893
Y->replaceUsesWithIf(NotY,
28932894
[NotY](Use &U) { return U.getUser() != NotY; });
28942895
}

llvm/test/Transforms/InstCombine/xor-of-icmps-with-extra-uses.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2-
; RUN: opt < %s -instcombine -S | FileCheck %s
2+
; RUN: opt < %s -instcombine -instcombine-infinite-loop-threshold=2 -S | FileCheck %s
33

44
; These xor-of-icmps could be replaced with and-of-icmps, but %cond0 has extra
55
; uses, so we don't consider it, even though some cases are freely invertible.

0 commit comments

Comments
 (0)