Index: llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp =================================================================== --- llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp +++ llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp @@ -8141,6 +8141,18 @@ return DAG.getSetCC(DL, ResultVT, Op, Op, IsInverted ? ISD::SETO : ISD::SETUO); } + + if (Test == fcInf && + isCondCodeLegalOrCustom(IsInverted ? ISD::SETUNE : ISD::SETOEQ, + OperandVT.getScalarType().getSimpleVT()) && + isOperationLegalOrCustom(ISD::FABS, OperandVT.getScalarType())) { + // isinf(x) --> fabs(x) == inf + SDValue Abs = DAG.getNode(ISD::FABS, DL, OperandVT, Op); + SDValue Inf = + DAG.getConstantFP(APFloat::getInf(Semantics), DL, OperandVT); + return DAG.getSetCC(DL, ResultVT, Abs, Inf, + IsInverted ? ISD::SETUNE : ISD::SETOEQ); + } } // In the general case use integer operations. Index: llvm/test/CodeGen/PowerPC/is_fpclass.ll =================================================================== --- llvm/test/CodeGen/PowerPC/is_fpclass.ll +++ llvm/test/CodeGen/PowerPC/is_fpclass.ll @@ -117,13 +117,12 @@ define i1 @isinf_ppc_fp128(ppc_fp128 %x) nounwind { ; CHECK-LABEL: isinf_ppc_fp128: ; CHECK: # %bb.0: -; CHECK-NEXT: mffprd 3, 1 -; CHECK-NEXT: li 4, 2047 -; CHECK-NEXT: clrldi 3, 3, 1 -; CHECK-NEXT: rldic 4, 4, 52, 1 -; CHECK-NEXT: cmpd 3, 4 -; CHECK-NEXT: li 3, 0 +; CHECK-NEXT: addis 3, 2, .LCPI9_0@toc@ha +; CHECK-NEXT: xsabsdp 0, 1 ; CHECK-NEXT: li 4, 1 +; CHECK-NEXT: lfs 1, .LCPI9_0@toc@l(3) +; CHECK-NEXT: li 3, 0 +; CHECK-NEXT: fcmpu 0, 0, 1 ; CHECK-NEXT: iseleq 3, 4, 3 ; CHECK-NEXT: blr %1 = call i1 @llvm.is.fpclass.ppcf128(ppc_fp128 %x, i32 516) ; 0x204 = "inf"