mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-09-30 19:55:11 +00:00
simplify code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59390 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a74cefa6d3
commit
a6a474dca9
@ -4210,30 +4210,25 @@ Instruction *InstCombiner::MatchBSwap(BinaryOperator &I) {
|
|||||||
/// we can simplify this expression to "cond ? C : D or B".
|
/// we can simplify this expression to "cond ? C : D or B".
|
||||||
static Instruction *MatchSelectFromAndOr(Value *A, Value *B,
|
static Instruction *MatchSelectFromAndOr(Value *A, Value *B,
|
||||||
Value *C, Value *D) {
|
Value *C, Value *D) {
|
||||||
// If A is not a select of constants, this can't match.
|
// If A is not a select of -1/0, this cannot match.
|
||||||
Value *Cond = 0, *Cond2 = 0;
|
Value *Cond = 0, *Cond2 = 0;
|
||||||
ConstantInt *C1, *C2;
|
if (!match(A, m_Select(m_Value(Cond), m_ConstantInt(-1), m_ConstantInt(0))))
|
||||||
if (!match(A, m_Select(m_Value(Cond), m_ConstantInt(C1), m_ConstantInt(C2))))
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
#define SELECT_MATCH(Val, I1, I2) \
|
#define SELECT_MATCH(Val, I1, I2) \
|
||||||
m_Select(m_Value(Val), m_ConstantInt(I1), m_ConstantInt(I2))
|
m_Select(m_Value(Val), m_ConstantInt(I1), m_ConstantInt(I2))
|
||||||
|
|
||||||
// Handle "cond ? -1 : 0".
|
// ((cond?-1:0)&C) | (B&(cond?0:-1)) -> cond ? C : B.
|
||||||
if (C1->isAllOnesValue() && C2->isZero()) {
|
if (match(D, SELECT_MATCH(Cond2, 0, -1)) && Cond2 == Cond)
|
||||||
// ((cond?-1:0)&C) | (B&(cond?0:-1)) -> cond ? C : B.
|
return SelectInst::Create(Cond, C, B);
|
||||||
if (match(D, SELECT_MATCH(Cond2, 0, -1)) && Cond2 == Cond)
|
if (match(D, m_Not(SELECT_MATCH(Cond2, -1, 0))) && Cond2 == Cond)
|
||||||
return SelectInst::Create(Cond, C, B);
|
return SelectInst::Create(Cond, C, B);
|
||||||
if (match(D, m_Not(SELECT_MATCH(Cond2, -1, 0))) && Cond2 == Cond)
|
// ((cond?-1:0)&C) | ((cond?0:-1)&D) -> cond ? C : D.
|
||||||
return SelectInst::Create(Cond, C, B);
|
if (match(B, SELECT_MATCH(Cond2, 0, -1)) && Cond2 == Cond)
|
||||||
// ((cond?-1:0)&C) | ((cond?0:-1)&D) -> cond ? C : D.
|
return SelectInst::Create(Cond, C, D);
|
||||||
if (match(B, SELECT_MATCH(Cond2, 0, -1)) && Cond2 == Cond)
|
if (match(B, m_Not(SELECT_MATCH(Cond2, -1, 0))) && Cond2 == Cond)
|
||||||
return SelectInst::Create(Cond, C, D);
|
return SelectInst::Create(Cond, C, D);
|
||||||
if (match(B, m_Not(SELECT_MATCH(Cond2, -1, 0))) && Cond2 == Cond)
|
|
||||||
return SelectInst::Create(Cond, C, D);
|
|
||||||
}
|
|
||||||
#undef SELECT_MATCH
|
#undef SELECT_MATCH
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user