mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-24 21:14:56 +00:00
Added InstCombine Transform for ((B | C) & A) | B -> B | (A & C)
Transform ((B | C) & A) | B --> B | (A & C) Z3 Link: http://rise4fun.com/Z3/hP6p Patch by Sonam Kumari! Differential Revision: http://reviews.llvm.org/D4865 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215619 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
0086358325
commit
923556f8a8
@ -2124,6 +2124,10 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) {
|
||||
if (Op0->hasOneUse() || cast<BinaryOperator>(Op0)->hasOneUse())
|
||||
return BinaryOperator::CreateOr(Op1, C);
|
||||
|
||||
// ((B | C) & A) | B -> B | (A & C)
|
||||
if (match(Op0, m_And(m_Or(m_Specific(Op1), m_Value(C)), m_Value(A))))
|
||||
return BinaryOperator::CreateOr(Op1, Builder->CreateAnd(A, C));
|
||||
|
||||
// (X >> Z) | (Y >> Z) -> (X|Y) >> Z for all shifts.
|
||||
if (BinaryOperator *SI1 = dyn_cast<BinaryOperator>(Op1)) {
|
||||
if (BinaryOperator *SI0 = dyn_cast<BinaryOperator>(Op0))
|
||||
|
@ -469,3 +469,14 @@ define i32 @test44(i32 %a, i32 %b) {
|
||||
%or = or i32 %xor, %and
|
||||
ret i32 %or
|
||||
}
|
||||
|
||||
define i32 @test45(i32 %x, i32 %y, i32 %z) {
|
||||
; CHECK-LABEL: test45(
|
||||
; CHECK-NEXT: %1 = and i32 %x, %z
|
||||
; CHECK-NEXT: %or1 = or i32 %1, %y
|
||||
; CHECK-NEXT: ret i32 %or1
|
||||
%or = or i32 %y, %z
|
||||
%and = and i32 %x, %or
|
||||
%or1 = or i32 %and, %y
|
||||
ret i32 %or1
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user