@@ -8817,6 +8817,31 @@ SDValue TargetLowering::expandIS_FPCLASS(EVT ResultVT, SDValue Op,
8817
8817
IsOrdered ? OrderedOp : UnorderedOp);
8818
8818
}
8819
8819
}
8820
+
8821
+ if (FPTestMask == fcNormal) {
8822
+ // TODO: Handle unordered
8823
+ ISD::CondCode IsFiniteOp = IsInvertedFP ? ISD::SETUGE : ISD::SETOLT;
8824
+ ISD::CondCode IsNormalOp = IsInvertedFP ? ISD::SETOLT : ISD::SETUGE;
8825
+
8826
+ if (isCondCodeLegalOrCustom (IsFiniteOp,
8827
+ OperandVT.getScalarType ().getSimpleVT ()) &&
8828
+ isCondCodeLegalOrCustom (IsNormalOp,
8829
+ OperandVT.getScalarType ().getSimpleVT ()) &&
8830
+ isFAbsFree (OperandVT)) {
8831
+ // isnormal(x) --> fabs(x) < infinity && !(fabs(x) < smallest_normal)
8832
+ SDValue Inf =
8833
+ DAG.getConstantFP (APFloat::getInf (Semantics), DL, OperandVT);
8834
+ SDValue SmallestNormal = DAG.getConstantFP (
8835
+ APFloat::getSmallestNormalized (Semantics), DL, OperandVT);
8836
+
8837
+ SDValue Abs = DAG.getNode (ISD::FABS, DL, OperandVT, Op);
8838
+ SDValue IsFinite = DAG.getSetCC (DL, ResultVT, Abs, Inf, IsFiniteOp);
8839
+ SDValue IsNormal =
8840
+ DAG.getSetCC (DL, ResultVT, Abs, SmallestNormal, IsNormalOp);
8841
+ unsigned LogicOp = IsInvertedFP ? ISD::OR : ISD::AND;
8842
+ return DAG.getNode (LogicOp, DL, ResultVT, IsFinite, IsNormal);
8843
+ }
8844
+ }
8820
8845
}
8821
8846
8822
8847
// Some checks may be represented as inversion of simpler check, for example
0 commit comments