forked from OSchip/llvm-project
Swap the operands of a select node if the false (the second) operand is 0.
For example, this pattern (select (setcc lhs, rhs, cc), true, 0) is transformed to this one: (select (setcc lhs, rhs, inverse(cc)), 0, true) This enables MipsDAGToDAGISel::ReplaceUsesWithZeroReg (added in r152280) to replace 0 with $zero. llvm-svn: 152285
This commit is contained in:
parent
3f28ec28d5
commit
7dd7c08419
|
@ -576,6 +576,39 @@ static SDValue PerformSETCCCombine(SDNode *N, SelectionDAG& DAG,
|
||||||
return CreateCMovFP(DAG, Cond, True, False, N->getDebugLoc());
|
return CreateCMovFP(DAG, Cond, True, False, N->getDebugLoc());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static SDValue PerformSELECTCombine(SDNode *N, SelectionDAG& DAG,
|
||||||
|
TargetLowering::DAGCombinerInfo &DCI,
|
||||||
|
const MipsSubtarget* Subtarget) {
|
||||||
|
if (DCI.isBeforeLegalizeOps())
|
||||||
|
return SDValue();
|
||||||
|
|
||||||
|
SDValue SetCC = N->getOperand(0);
|
||||||
|
|
||||||
|
if ((SetCC.getOpcode() != ISD::SETCC) ||
|
||||||
|
!SetCC.getOperand(0).getValueType().isInteger())
|
||||||
|
return SDValue();
|
||||||
|
|
||||||
|
SDValue False = N->getOperand(2);
|
||||||
|
EVT FalseTy = False.getValueType();
|
||||||
|
|
||||||
|
if (!FalseTy.isInteger())
|
||||||
|
return SDValue();
|
||||||
|
|
||||||
|
ConstantSDNode *CN = dyn_cast<ConstantSDNode>(False);
|
||||||
|
|
||||||
|
if (!CN || CN->getZExtValue())
|
||||||
|
return SDValue();
|
||||||
|
|
||||||
|
const DebugLoc DL = N->getDebugLoc();
|
||||||
|
ISD::CondCode CC = cast<CondCodeSDNode>(SetCC.getOperand(2))->get();
|
||||||
|
SDValue True = N->getOperand(1);
|
||||||
|
|
||||||
|
SetCC = DAG.getSetCC(DL, SetCC.getValueType(), SetCC.getOperand(0),
|
||||||
|
SetCC.getOperand(1), ISD::getSetCCInverse(CC, true));
|
||||||
|
|
||||||
|
return DAG.getNode(ISD::SELECT, DL, FalseTy, SetCC, False, True);
|
||||||
|
}
|
||||||
|
|
||||||
static SDValue PerformANDCombine(SDNode *N, SelectionDAG& DAG,
|
static SDValue PerformANDCombine(SDNode *N, SelectionDAG& DAG,
|
||||||
TargetLowering::DAGCombinerInfo &DCI,
|
TargetLowering::DAGCombinerInfo &DCI,
|
||||||
const MipsSubtarget* Subtarget) {
|
const MipsSubtarget* Subtarget) {
|
||||||
|
@ -686,6 +719,8 @@ SDValue MipsTargetLowering::PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI)
|
||||||
return PerformDivRemCombine(N, DAG, DCI, Subtarget);
|
return PerformDivRemCombine(N, DAG, DCI, Subtarget);
|
||||||
case ISD::SETCC:
|
case ISD::SETCC:
|
||||||
return PerformSETCCCombine(N, DAG, DCI, Subtarget);
|
return PerformSETCCCombine(N, DAG, DCI, Subtarget);
|
||||||
|
case ISD::SELECT:
|
||||||
|
return PerformSELECTCombine(N, DAG, DCI, Subtarget);
|
||||||
case ISD::AND:
|
case ISD::AND:
|
||||||
return PerformANDCombine(N, DAG, DCI, Subtarget);
|
return PerformANDCombine(N, DAG, DCI, Subtarget);
|
||||||
case ISD::OR:
|
case ISD::OR:
|
||||||
|
|
Loading…
Reference in New Issue