From 67ca7689278d14c732db49bbd11869806148f266 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 12 Aug 2003 19:11:07 +0000 Subject: [PATCH] Implement testcases InstCombine/or.ll:test16/test17 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7782 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/InstructionCombining.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 83544743ff7..bfc51db1b71 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -612,6 +612,19 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) { } } + // (A & C1)|(A & C2) == A & (C1|C2) + if (BinaryOperator *BO0 = dyn_cast(Op0)) + if (BinaryOperator *BO1 = dyn_cast(Op1)) + if (BO0->getOperand(0) == BO1->getOperand(0) && + BO0->getOpcode() == Instruction::And && + BO1->getOpcode() == Instruction::And) + if (ConstantIntegral *C0 = + dyn_cast(BO0->getOperand(1))) + if (ConstantIntegral *C1 = + dyn_cast(BO1->getOperand(1))) + return BinaryOperator::create(Instruction::And, BO0->getOperand(0), + *C0 | *C1); + Value *Op0NotVal = dyn_castNotVal(Op0); Value *Op1NotVal = dyn_castNotVal(Op1); -- 2.34.1