[llvm] 672e8bf - [InstCombine] Fix worklist management in foldXorOfICmps()
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 28 10:25:34 PDT 2020
Author: Nikita Popov
Date: 2020-03-28T18:25:21+01:00
New Revision: 672e8bfbfcddcc63e5940c50bb94d56ac6e96a58
URL: https://github.com/llvm/llvm-project/commit/672e8bfbfcddcc63e5940c50bb94d56ac6e96a58
DIFF: https://github.com/llvm/llvm-project/commit/672e8bfbfcddcc63e5940c50bb94d56ac6e96a58.diff
LOG: [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.
Added:
Modified:
llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
llvm/test/Transforms/InstCombine/xor-of-icmps-with-extra-uses.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
index d07fc857eedf..01ba1031fb72 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 a795ead93e54..fef919678742 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.
More information about the llvm-commits
mailing list