[llvm-commits] [llvm] r126082 - in /llvm/trunk/lib: Analysis/InstructionSimplify.cpp Transforms/InstCombine/InstCombineAndOrXor.cpp
Benjamin Kramer
benny.kra at googlemail.com
Sun Feb 20 07:20:01 PST 2011
Author: d0k
Date: Sun Feb 20 09:20:01 2011
New Revision: 126082
URL: http://llvm.org/viewvc/llvm-project?rev=126082&view=rev
Log:
Move "A | ~(A & ?) -> -1" from InstCombine to InstructionSimplify.
Modified:
llvm/trunk/lib/Analysis/InstructionSimplify.cpp
llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
Modified: llvm/trunk/lib/Analysis/InstructionSimplify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InstructionSimplify.cpp?rev=126082&r1=126081&r2=126082&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/InstructionSimplify.cpp (original)
+++ llvm/trunk/lib/Analysis/InstructionSimplify.cpp Sun Feb 20 09:20:01 2011
@@ -1161,6 +1161,16 @@
(A == Op0 || B == Op0))
return Op0;
+ // ~(A & ?) | A = -1
+ if (match(Op0, m_Not(m_And(m_Value(A), m_Value(B)))) &&
+ (A == Op1 || B == Op1))
+ return Constant::getAllOnesValue(Op1->getType());
+
+ // A | ~(A & ?) = -1
+ if (match(Op1, m_Not(m_And(m_Value(A), m_Value(B)))) &&
+ (A == Op0 || B == Op0))
+ return Constant::getAllOnesValue(Op0->getType());
+
// Try some generic simplifications for associative operations.
if (Value *V = SimplifyAssociativeBinOp(Instruction::Or, Op0, Op1, TD, DT,
MaxRecurse))
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp?rev=126082&r1=126081&r2=126082&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp Sun Feb 20 09:20:01 2011
@@ -1919,24 +1919,16 @@
// A | ~(A | B) -> A | ~B
// A | ~(A ^ B) -> A | ~B
- // A | ~(A & B) -> -1
if (match(Op1, m_Not(m_Value(A))))
if (BinaryOperator *B = dyn_cast<BinaryOperator>(A))
- if (Op0 == B->getOperand(0) || Op0 == B->getOperand(1))
- switch (B->getOpcode()) {
- default: break;
- case Instruction::Or:
- case Instruction::Xor:
- if (Op1->hasOneUse()) {
- Value *NotOp = Op0 == B->getOperand(0) ? B->getOperand(1) :
- B->getOperand(0);
- Value *Not = Builder->CreateNot(NotOp, NotOp->getName()+".not");
- return BinaryOperator::CreateOr(Not, Op0);
- }
- break;
- case Instruction::And:
- return ReplaceInstUsesWith(I, Constant::getAllOnesValue(I.getType()));
- }
+ if ((Op0 == B->getOperand(0) || Op0 == B->getOperand(1)) &&
+ Op1->hasOneUse() && (B->getOpcode() == Instruction::Or ||
+ B->getOpcode() == Instruction::Xor)) {
+ Value *NotOp = Op0 == B->getOperand(0) ? B->getOperand(1) :
+ B->getOperand(0);
+ Value *Not = Builder->CreateNot(NotOp, NotOp->getName()+".not");
+ return BinaryOperator::CreateOr(Not, Op0);
+ }
if (ICmpInst *RHS = dyn_cast<ICmpInst>(I.getOperand(1)))
if (ICmpInst *LHS = dyn_cast<ICmpInst>(I.getOperand(0)))
More information about the llvm-commits
mailing list