Skip to content

Commit 8bb4921

Browse files
committedAug 13, 2018
[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 llvm-svn: 339531
1 parent 3b2a17b commit 8bb4921

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed
 

‎llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -2507,9 +2507,15 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) {
25072507
if (Value *V = SimplifyBSwap(I, Builder))
25082508
return replaceInstUsesWith(I, V);
25092509

2510-
// A^B --> A|B iff A and B have no bits set in common.
25112510
Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);
2512-
if (haveNoCommonBitsSet(Op0, Op1, DL, &AC, &I, &DT))
2511+
2512+
// Fold (X & M) ^ (Y & ~M) -> (X & M) | (Y & ~M)
2513+
// This it a special case in haveNoCommonBitsSet, but the commputeKnownBits
2514+
// calls in there are unnecessary as SimplifyDemandedInstructionBits should
2515+
// have already taken care of those cases.
2516+
Value *M;
2517+
if (match(&I, m_c_Xor(m_c_And(m_Not(m_Value(M)), m_Value()),
2518+
m_c_And(m_Deferred(M), m_Value()))))
25132519
return BinaryOperator::CreateOr(Op0, Op1);
25142520

25152521
// Apply DeMorgan's Law for 'nand' / 'nor' logic with an inverted operand.

0 commit comments

Comments
 (0)
Please sign in to comment.