Implement Instcombine/and.ll:test34
authorChris Lattner <sabre@nondot.org>
Mon, 13 Feb 2006 23:07:23 +0000 (23:07 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 13 Feb 2006 23:07:23 +0000 (23:07 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26155 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/InstructionCombining.cpp

index d42e0bbdf91e73aaab9d0fad09d1c7a92711fb45..3266ffdae31b99e430ce8f89961b859e62a59871 100644 (file)
@@ -2439,6 +2439,18 @@ Instruction *InstCombiner::visitAnd(BinaryOperator &I) {
     InsertNewInstBefore(Or, I);
     return BinaryOperator::createNot(Or);
   }
+  
+  {
+    Value *A = 0, *B = 0;
+    ConstantInt *C1 = 0, *C2 = 0;
+    if (match(Op0, m_Or(m_Value(A), m_Value(B))))
+      if (A == Op1 || B == Op1)    // (A | ?) & A  --> A
+        return ReplaceInstUsesWith(I, Op1);
+    if (match(Op1, m_Or(m_Value(A), m_Value(B))))
+      if (A == Op0 || B == Op0)    // A & (A | ?)  --> A
+        return ReplaceInstUsesWith(I, Op0);
+  }
+  
 
   if (SetCondInst *RHS = dyn_cast<SetCondInst>(Op1)) {
     // (setcc1 A, B) & (setcc2 A, B) --> (setcc3 A, B)