mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 19:23:23 +01:00
[DAG] clean up foldSelectOfConstants(); NFCI
Rename variables, simplify logic. Not clear yet why we don't handle a target with ZeroOrNegativeOneBooleanContent too. llvm-svn: 283613
This commit is contained in:
parent
99e8d201a0
commit
1d88c15c1d
@ -5108,13 +5108,14 @@ static SDValue combineMinNumMaxNum(const SDLoc &DL, EVT VT, SDValue LHS,
|
||||
|
||||
// TODO: We should handle other cases of selecting between {-1,0,1} here.
|
||||
SDValue DAGCombiner::foldSelectOfConstants(SDNode *N) {
|
||||
SDValue N0 = N->getOperand(0);
|
||||
SDValue Cond = N->getOperand(0);
|
||||
SDValue N1 = N->getOperand(1);
|
||||
SDValue N2 = N->getOperand(2);
|
||||
EVT VT = N->getValueType(0);
|
||||
EVT VT0 = N0.getValueType();
|
||||
EVT CondVT = Cond.getValueType();
|
||||
SDLoc DL(N);
|
||||
|
||||
// fold (select C, 0, 1) -> (xor C, 1)
|
||||
// fold (select Cond, 0, 1) -> (xor Cond, 1)
|
||||
// We can't do this reliably if integer based booleans have different contents
|
||||
// to floating point based booleans. This is because we can't tell whether we
|
||||
// have an integer-based boolean or a floating-point-based boolean unless we
|
||||
@ -5124,23 +5125,17 @@ SDValue DAGCombiner::foldSelectOfConstants(SDNode *N) {
|
||||
// in another basic block or it could require searching a complicated
|
||||
// expression.
|
||||
if (VT.isInteger() &&
|
||||
(VT0 == MVT::i1 || (VT0.isInteger() &&
|
||||
TLI.getBooleanContents(false, false) ==
|
||||
TLI.getBooleanContents(false, true) &&
|
||||
TLI.getBooleanContents(false, false) ==
|
||||
TargetLowering::ZeroOrOneBooleanContent)) &&
|
||||
(CondVT == MVT::i1 || (CondVT.isInteger() &&
|
||||
TLI.getBooleanContents(false, true) ==
|
||||
TargetLowering::ZeroOrOneBooleanContent &&
|
||||
TLI.getBooleanContents(false, false) ==
|
||||
TargetLowering::ZeroOrOneBooleanContent)) &&
|
||||
isNullConstant(N1) && isOneConstant(N2)) {
|
||||
SDValue XORNode;
|
||||
if (VT == VT0) {
|
||||
SDLoc DL(N);
|
||||
return DAG.getNode(ISD::XOR, DL, VT0, N0, DAG.getConstant(1, DL, VT0));
|
||||
}
|
||||
SDLoc DL0(N0);
|
||||
XORNode = DAG.getNode(ISD::XOR, DL0, VT0, N0, DAG.getConstant(1, DL0, VT0));
|
||||
AddToWorklist(XORNode.getNode());
|
||||
if (VT.bitsGT(VT0))
|
||||
return DAG.getNode(ISD::ZERO_EXTEND, SDLoc(N), VT, XORNode);
|
||||
return DAG.getNode(ISD::TRUNCATE, SDLoc(N), VT, XORNode);
|
||||
SDValue NotCond = DAG.getNode(ISD::XOR, DL, CondVT, Cond,
|
||||
DAG.getConstant(1, DL, CondVT));
|
||||
if (VT.bitsEq(CondVT))
|
||||
return NotCond;
|
||||
return DAG.getZExtOrTrunc(NotCond, DL, VT);
|
||||
}
|
||||
|
||||
return SDValue();
|
||||
|
Loading…
Reference in New Issue
Block a user