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