mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 19:23:23 +01:00
Fold setcc of MVT::i1 operands into logical operations
llvm-svn: 21319
This commit is contained in:
parent
72aca1b758
commit
188ecaab1d
@ -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),
|
||||
std::make_pair(Cond, VT))];
|
||||
if (N) return SDOperand(N, 0);
|
||||
|
Loading…
Reference in New Issue
Block a user