diff options
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp')
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp | 37 | 
1 files changed, 37 insertions, 0 deletions
| diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp index 7bd85fdb960..a2baee42310 100644 --- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp @@ -1922,6 +1922,43 @@ TargetLowering::SimplifySetCC(EVT VT, SDValue N0, SDValue N1,      // materialize 0.0.      if (Cond == ISD::SETO || Cond == ISD::SETUO)        return DAG.getSetCC(dl, VT, N0, N0, Cond); + +    // If the condition is not legal, see if we can find an equivalent one +    // which is legal. +    if (!isCondCodeLegal(Cond, N0.getValueType())) { +      // If the comparison was an awkward floating-point == or != and one of +      // 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.getValueType())) +            return DAG.getSetCC(dl, VT, N0, N1, ISD::SETOLE); +          if (Cond == ISD::SETUEQ && +              isCondCodeLegal(ISD::SETOLE, N0.getValueType())) +            return DAG.getSetCC(dl, VT, N0, N1, ISD::SETULE); +          if (Cond == ISD::SETUNE && +              isCondCodeLegal(ISD::SETUGT, N0.getValueType())) +            return DAG.getSetCC(dl, VT, N0, N1, ISD::SETUGT); +          if (Cond == ISD::SETONE && +              isCondCodeLegal(ISD::SETUGT, N0.getValueType())) +            return DAG.getSetCC(dl, VT, N0, N1, ISD::SETOGT); +        } else { +          if (Cond == ISD::SETOEQ && +              isCondCodeLegal(ISD::SETOGE, N0.getValueType())) +            return DAG.getSetCC(dl, VT, N0, N1, ISD::SETOGE); +          if (Cond == ISD::SETUEQ && +              isCondCodeLegal(ISD::SETOGE, N0.getValueType())) +            return DAG.getSetCC(dl, VT, N0, N1, ISD::SETUGE); +          if (Cond == ISD::SETUNE && +              isCondCodeLegal(ISD::SETULT, N0.getValueType())) +            return DAG.getSetCC(dl, VT, N0, N1, ISD::SETULT); +          if (Cond == ISD::SETONE && +              isCondCodeLegal(ISD::SETULT, N0.getValueType())) +            return DAG.getSetCC(dl, VT, N0, N1, ISD::SETOLT); +        } +      } +    }    }    if (N0 == N1) { | 

