[llvm] r339531 - [InstCombine] Replace call to haveNoCommonBitsSet in visitXor with just the special case that doesn't use computeKnownBits.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 12 17:38:28 PDT 2018
Author: ctopper
Date: Sun Aug 12 17:38:27 2018
New Revision: 339531
URL: http://llvm.org/viewvc/llvm-project?rev=339531&view=rev
Log:
[InstCombine] Replace call to haveNoCommonBitsSet in visitXor with just the special case that doesn't use computeKnownBits.
Summary: computeKnownBits is expensive. The cases that would be detected by the computeKnownBits portion of haveNoCommonBitsSet were already handled by the earlier call to SimplifyDemandedInstructionBits.
Reviewers: spatel, lebedev.ri
Reviewed By: lebedev.ri
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D50604
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp?rev=339531&r1=339530&r2=339531&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp Sun Aug 12 17:38:27 2018
@@ -2507,9 +2507,15 @@ Instruction *InstCombiner::visitXor(Bina
if (Value *V = SimplifyBSwap(I, Builder))
return replaceInstUsesWith(I, V);
- // A^B --> A|B iff A and B have no bits set in common.
Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);
- if (haveNoCommonBitsSet(Op0, Op1, DL, &AC, &I, &DT))
+
+ // Fold (X & M) ^ (Y & ~M) -> (X & M) | (Y & ~M)
+ // This it a special case in haveNoCommonBitsSet, but the commputeKnownBits
+ // calls in there are unnecessary as SimplifyDemandedInstructionBits should
+ // have already taken care of those cases.
+ Value *M;
+ if (match(&I, m_c_Xor(m_c_And(m_Not(m_Value(M)), m_Value()),
+ m_c_And(m_Deferred(M), m_Value()))))
return BinaryOperator::CreateOr(Op0, Op1);
// Apply DeMorgan's Law for 'nand' / 'nor' logic with an inverted operand.
More information about the llvm-commits
mailing list