diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp index d07fc857eedfd..01ba1031fb726 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp @@ -2889,6 +2889,7 @@ Value *InstCombiner::foldXorOfICmps(ICmpInst *LHS, ICmpInst *RHS, Builder.SetInsertPoint(Y->getParent(), ++(Y->getIterator())); Value *NotY = Builder.CreateNot(Y, Y->getName() + ".not"); // Replace all uses of Y (excluding the one in NotY!) with NotY. + Worklist.pushUsersToWorkList(*Y); Y->replaceUsesWithIf(NotY, [NotY](Use &U) { return U.getUser() != NotY; }); } diff --git a/llvm/test/Transforms/InstCombine/xor-of-icmps-with-extra-uses.ll b/llvm/test/Transforms/InstCombine/xor-of-icmps-with-extra-uses.ll index a795ead93e546..fef919678742c 100644 --- a/llvm/test/Transforms/InstCombine/xor-of-icmps-with-extra-uses.ll +++ b/llvm/test/Transforms/InstCombine/xor-of-icmps-with-extra-uses.ll @@ -1,5 +1,5 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py -; RUN: opt < %s -instcombine -S | FileCheck %s +; RUN: opt < %s -instcombine -instcombine-infinite-loop-threshold=2 -S | FileCheck %s ; These xor-of-icmps could be replaced with and-of-icmps, but %cond0 has extra ; uses, so we don't consider it, even though some cases are freely invertible.