@@ -8652,6 +8652,31 @@ SDValue TargetLowering::expandIS_FPCLASS(EVT ResultVT, SDValue Op,
8652
8652
return DAG.getSetCC(DL, ResultVT, Op, Inf,
8653
8653
IsOrdered ? OrderedCmpOpcode : UnorderedCmpOpcode);
8654
8654
}
8655
+
8656
+ if (FPTestMask == fcNormal) {
8657
+ // TODO: Handle unordered
8658
+ ISD::CondCode IsFiniteOp = IsInvertedFP ? ISD::SETUGE : ISD::SETOLT;
8659
+ ISD::CondCode IsNormalOp = IsInvertedFP ? ISD::SETOLT : ISD::SETUGE;
8660
+
8661
+ if (isCondCodeLegalOrCustom(IsFiniteOp,
8662
+ OperandVT.getScalarType().getSimpleVT()) &&
8663
+ isCondCodeLegalOrCustom(IsNormalOp,
8664
+ OperandVT.getScalarType().getSimpleVT()) &&
8665
+ isFAbsFree(OperandVT)) {
8666
+ // isnormal(x) --> fabs(x) < infinity && !(fabs(x) < smallest_normal)
8667
+ SDValue Inf =
8668
+ DAG.getConstantFP(APFloat::getInf(Semantics), DL, OperandVT);
8669
+ SDValue SmallestNormal = DAG.getConstantFP(
8670
+ APFloat::getSmallestNormalized(Semantics), DL, OperandVT);
8671
+
8672
+ SDValue Abs = DAG.getNode(ISD::FABS, DL, OperandVT, Op);
8673
+ SDValue IsFinite = DAG.getSetCC(DL, ResultVT, Abs, Inf, IsFiniteOp);
8674
+ SDValue IsNormal =
8675
+ DAG.getSetCC(DL, ResultVT, Abs, SmallestNormal, IsNormalOp);
8676
+ unsigned LogicOp = IsInvertedFP ? ISD::OR : ISD::AND;
8677
+ return DAG.getNode(LogicOp, DL, ResultVT, IsFinite, IsNormal);
8678
+ }
8679
+ }
8655
8680
}
8656
8681
8657
8682
// Some checks may be represented as inversion of simpler check, for example
0 commit comments