mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-12 17:32:19 +00:00
Fold setcc of MVT::i1 operands into logical operations
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21319 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
4a44c8df19
commit
fda2b55e1b
@ -597,6 +597,45 @@ SDOperand SelectionDAG::getSetCC(ISD::CondCode Cond, MVT::ValueType VT,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fold away ALL boolean setcc's.
|
||||||
|
if (N1.getValueType() == MVT::i1) {
|
||||||
|
switch (Cond) {
|
||||||
|
default: assert(0 && "Unknown integer setcc!");
|
||||||
|
case ISD::SETEQ: // X == Y -> (X^Y)^1
|
||||||
|
N1 = getNode(ISD::XOR, MVT::i1,
|
||||||
|
getNode(ISD::XOR, MVT::i1, N1, N2),
|
||||||
|
getConstant(1, MVT::i1));
|
||||||
|
break;
|
||||||
|
case ISD::SETNE: // X != Y --> (X^Y)
|
||||||
|
N1 = getNode(ISD::XOR, MVT::i1, N1, N2);
|
||||||
|
break;
|
||||||
|
case ISD::SETGT: // X >s Y --> X == 0 & Y == 1 --> X^1 & Y
|
||||||
|
case ISD::SETULT: // X <u Y --> X == 0 & Y == 1 --> X^1 & Y
|
||||||
|
N1 = getNode(ISD::AND, MVT::i1, N2,
|
||||||
|
getNode(ISD::XOR, MVT::i1, N1, getConstant(1, MVT::i1)));
|
||||||
|
break;
|
||||||
|
case ISD::SETLT: // X <s Y --> X == 1 & Y == 0 --> Y^1 & X
|
||||||
|
case ISD::SETUGT: // X >u Y --> X == 1 & Y == 0 --> Y^1 & X
|
||||||
|
N1 = getNode(ISD::AND, MVT::i1, N1,
|
||||||
|
getNode(ISD::XOR, MVT::i1, N2, getConstant(1, MVT::i1)));
|
||||||
|
break;
|
||||||
|
case ISD::SETULE: // X <=u Y --> X == 0 | Y == 1 --> X^1 | Y
|
||||||
|
case ISD::SETGE: // X >=s Y --> X == 0 | Y == 1 --> X^1 | Y
|
||||||
|
N1 = getNode(ISD::OR, MVT::i1, N2,
|
||||||
|
getNode(ISD::XOR, MVT::i1, N1, getConstant(1, MVT::i1)));
|
||||||
|
break;
|
||||||
|
case ISD::SETUGE: // X >=u Y --> X == 1 | Y == 0 --> Y^1 | X
|
||||||
|
case ISD::SETLE: // X <=s Y --> X == 1 | Y == 0 --> Y^1 | X
|
||||||
|
N1 = getNode(ISD::OR, MVT::i1, N1,
|
||||||
|
getNode(ISD::XOR, MVT::i1, N2, getConstant(1, MVT::i1)));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (VT != MVT::i1)
|
||||||
|
N1 = getNode(ISD::ZERO_EXTEND, VT, N1);
|
||||||
|
return N1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
SetCCSDNode *&N = SetCCs[std::make_pair(std::make_pair(N1, N2),
|
SetCCSDNode *&N = SetCCs[std::make_pair(std::make_pair(N1, N2),
|
||||||
std::make_pair(Cond, VT))];
|
std::make_pair(Cond, VT))];
|
||||||
if (N) return SDOperand(N, 0);
|
if (N) return SDOperand(N, 0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user