[llvm] f7f430c - [InstCombine] Fixed non-determinisctic order of new instructions
Stanislav Mekhanoshin via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 28 12:16:10 PDT 2021
Author: Stanislav Mekhanoshin
Date: 2021-10-28T12:14:02-07:00
New Revision: f7f430c9136330545637aaddebf013da05c0f370
URL: https://github.com/llvm/llvm-project/commit/f7f430c9136330545637aaddebf013da05c0f370
DIFF: https://github.com/llvm/llvm-project/commit/f7f430c9136330545637aaddebf013da05c0f370.diff
LOG: [InstCombine] Fixed non-determinisctic order of new instructions
Fixes non-determinisctic order of XOR instructions created after
5a7a458306cd. The order of call argument evaluation is not
defined, so create one Value before the call.
Added:
Modified:
llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
index 5ef1145e0985..ac79e21507c5 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
@@ -2805,15 +2805,17 @@ Instruction *InstCombinerImpl::visitOr(BinaryOperator &I) {
m_Value(C))))) {
if (match(Op1, m_OneUse(m_c_And(
m_OneUse(m_Not(m_c_Or(m_Specific(A), m_Specific(C)))),
- m_Specific(B)))))
- return BinaryOperator::CreateAnd(Builder.CreateXor(B, C),
- Builder.CreateNot(A));
+ m_Specific(B))))) {
+ Value *Xor = Builder.CreateXor(B, C);
+ return BinaryOperator::CreateAnd(Xor, Builder.CreateNot(A));
+ }
if (match(Op1, m_OneUse(m_c_And(
m_OneUse(m_Not(m_c_Or(m_Specific(B), m_Specific(C)))),
- m_Specific(A)))))
- return BinaryOperator::CreateAnd(Builder.CreateXor(A, C),
- Builder.CreateNot(B));
+ m_Specific(A))))) {
+ Value *Xor = Builder.CreateXor(A, C);
+ return BinaryOperator::CreateAnd(Xor, Builder.CreateNot(B));
+ }
}
if (Instruction *DeMorgan = matchDeMorgansLaws(I, Builder))
More information about the llvm-commits
mailing list