[TargetLowering] Fix what look like copy/paste mistakes in compare with infinity handling SimplifySetCC.
I expect that the isCondCodeLegal checks should match that CC of the node that we're going to create. Rewriting to a switch to minimize repeated mentions of the same constants.
This commit is contained in:
parent
80bf137fa1
commit
adc69729ec
|
@ -3864,33 +3864,17 @@ SDValue TargetLowering::SimplifySetCC(EVT VT, SDValue N0, SDValue N1,
|
|||
// the comparison operands is infinity or negative infinity, convert the
|
||||
// condition to a less-awkward <= or >=.
|
||||
if (CFP->getValueAPF().isInfinity()) {
|
||||
if (CFP->getValueAPF().isNegative()) {
|
||||
if (Cond == ISD::SETOEQ &&
|
||||
isCondCodeLegal(ISD::SETOLE, N0.getSimpleValueType()))
|
||||
return DAG.getSetCC(dl, VT, N0, N1, ISD::SETOLE);
|
||||
if (Cond == ISD::SETUEQ &&
|
||||
isCondCodeLegal(ISD::SETOLE, N0.getSimpleValueType()))
|
||||
return DAG.getSetCC(dl, VT, N0, N1, ISD::SETULE);
|
||||
if (Cond == ISD::SETUNE &&
|
||||
isCondCodeLegal(ISD::SETUGT, N0.getSimpleValueType()))
|
||||
return DAG.getSetCC(dl, VT, N0, N1, ISD::SETUGT);
|
||||
if (Cond == ISD::SETONE &&
|
||||
isCondCodeLegal(ISD::SETUGT, N0.getSimpleValueType()))
|
||||
return DAG.getSetCC(dl, VT, N0, N1, ISD::SETOGT);
|
||||
} else {
|
||||
if (Cond == ISD::SETOEQ &&
|
||||
isCondCodeLegal(ISD::SETOGE, N0.getSimpleValueType()))
|
||||
return DAG.getSetCC(dl, VT, N0, N1, ISD::SETOGE);
|
||||
if (Cond == ISD::SETUEQ &&
|
||||
isCondCodeLegal(ISD::SETOGE, N0.getSimpleValueType()))
|
||||
return DAG.getSetCC(dl, VT, N0, N1, ISD::SETUGE);
|
||||
if (Cond == ISD::SETUNE &&
|
||||
isCondCodeLegal(ISD::SETULT, N0.getSimpleValueType()))
|
||||
return DAG.getSetCC(dl, VT, N0, N1, ISD::SETULT);
|
||||
if (Cond == ISD::SETONE &&
|
||||
isCondCodeLegal(ISD::SETULT, N0.getSimpleValueType()))
|
||||
return DAG.getSetCC(dl, VT, N0, N1, ISD::SETOLT);
|
||||
bool IsNegInf = CFP->getValueAPF().isNegative();
|
||||
ISD::CondCode NewCond = ISD::SETCC_INVALID;
|
||||
switch (Cond) {
|
||||
case ISD::SETOEQ: NewCond = IsNegInf ? ISD::SETOLE : ISD::SETOGE; break;
|
||||
case ISD::SETUEQ: NewCond = IsNegInf ? ISD::SETULE : ISD::SETUGE; break;
|
||||
case ISD::SETUNE: NewCond = IsNegInf ? ISD::SETUGT : ISD::SETULT; break;
|
||||
case ISD::SETONE: NewCond = IsNegInf ? ISD::SETOGT : ISD::SETOLT; break;
|
||||
}
|
||||
if (NewCond != ISD::SETCC_INVALID &&
|
||||
isCondCodeLegal(NewCond, N0.getSimpleValueType()))
|
||||
return DAG.getSetCC(dl, VT, N0, N1, NewCond);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue