implement or.ll:test20
authorChris Lattner <sabre@nondot.org>
Fri, 6 May 2005 00:58:50 +0000 (00:58 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 6 May 2005 00:58:50 +0000 (00:58 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21709 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/InstructionCombining.cpp

index fa615cfc5178361bb2027bd7519a2a6a534aa02f..7fed5aa8c697b349bd656ccbc855de1775a5edba 100644 (file)
@@ -1872,6 +1872,13 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) {
     A = 0;
   }
 
+  if (match(Op0, m_And(m_Value(A), m_Value(B))))
+    if (A == Op1 || B == Op1)    // (A & ?) | A  --> A
+      return ReplaceInstUsesWith(I, Op1);
+  if (match(Op1, m_And(m_Value(A), m_Value(B))))
+    if (A == Op0 || B == Op0)    // A | (A & ?)  --> A
+      return ReplaceInstUsesWith(I, Op0);
+
   if (match(Op1, m_Not(m_Value(B)))) {   // Op0 | ~B
     if (Op0 == B)
       return ReplaceInstUsesWith(I,