mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-24 23:28:41 +00:00
Teach InstructionSimplify to fold (A & B) & A -> A & B and (A | B) | A -> A | B.
Reassociate does this but it doesn't catch all cases (e.g. if the operands are i1). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@113651 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -106,6 +106,16 @@ Value *llvm::SimplifyAndInst(Value *Op0, Value *Op1, const TargetData *TD) {
|
||||
(A == Op0 || B == Op0))
|
||||
return Op0;
|
||||
|
||||
// (A & B) & A -> A & B
|
||||
if (match(Op0, m_And(m_Value(A), m_Value(B))) &&
|
||||
(A == Op1 || B == Op1))
|
||||
return Op0;
|
||||
|
||||
// A & (A & B) -> A & B
|
||||
if (match(Op1, m_And(m_Value(A), m_Value(B))) &&
|
||||
(A == Op0 || B == Op0))
|
||||
return Op1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -165,6 +175,16 @@ Value *llvm::SimplifyOrInst(Value *Op0, Value *Op1, const TargetData *TD) {
|
||||
(A == Op0 || B == Op0))
|
||||
return Op0;
|
||||
|
||||
// (A | B) | A -> A | B
|
||||
if (match(Op0, m_Or(m_Value(A), m_Value(B))) &&
|
||||
(A == Op1 || B == Op1))
|
||||
return Op0;
|
||||
|
||||
// A | (A | B) -> A | B
|
||||
if (match(Op1, m_Or(m_Value(A), m_Value(B))) &&
|
||||
(A == Op0 || B == Op0))
|
||||
return Op1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user