@@ -8790,6 +8790,31 @@ SDValue TargetLowering::expandIS_FPCLASS(EVT ResultVT, SDValue Op,
8790
8790
IsOrdered ? OrderedOp : UnorderedOp);
8791
8791
}
8792
8792
}
8793
+
8794
+ if (FPTestMask == fcNormal) {
8795
+ // TODO: Handle unordered
8796
+ ISD::CondCode IsFiniteOp = IsInvertedFP ? ISD::SETUGE : ISD::SETOLT;
8797
+ ISD::CondCode IsNormalOp = IsInvertedFP ? ISD::SETOLT : ISD::SETUGE;
8798
+
8799
+ if (isCondCodeLegalOrCustom (IsFiniteOp,
8800
+ OperandVT.getScalarType ().getSimpleVT ()) &&
8801
+ isCondCodeLegalOrCustom (IsNormalOp,
8802
+ OperandVT.getScalarType ().getSimpleVT ()) &&
8803
+ isFAbsFree (OperandVT)) {
8804
+ // isnormal(x) --> fabs(x) < infinity && !(fabs(x) < smallest_normal)
8805
+ SDValue Inf =
8806
+ DAG.getConstantFP (APFloat::getInf (Semantics), DL, OperandVT);
8807
+ SDValue SmallestNormal = DAG.getConstantFP (
8808
+ APFloat::getSmallestNormalized (Semantics), DL, OperandVT);
8809
+
8810
+ SDValue Abs = DAG.getNode (ISD::FABS, DL, OperandVT, Op);
8811
+ SDValue IsFinite = DAG.getSetCC (DL, ResultVT, Abs, Inf, IsFiniteOp);
8812
+ SDValue IsNormal =
8813
+ DAG.getSetCC (DL, ResultVT, Abs, SmallestNormal, IsNormalOp);
8814
+ unsigned LogicOp = IsInvertedFP ? ISD::OR : ISD::AND;
8815
+ return DAG.getNode (LogicOp, DL, ResultVT, IsFinite, IsNormal);
8816
+ }
8817
+ }
8793
8818
}
8794
8819
8795
8820
// Some checks may be represented as inversion of simpler check, for example
0 commit comments