[llvm] [APFloat][SelectionDAG] Support Float8E5M3FNU in `convert.{to,from}.arbitrary.fp` (PR #216387)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 17 11:48:41 PDT 2026


================
@@ -9739,6 +9746,19 @@ SDValue TargetLowering::expandCONVERT_TO_ARBITRARY_FP(SDNode *Node,
   SDValue Result = FiniteResult;
   Result = DAG.getSelect(dl, IntVT, IsZero, ZeroResult, Result);
   Result = DAG.getSelect(dl, IntVT, IsInf, InfResult, Result);
+
+  // An unsigned destination format cannot encode a negative value. -0.0 is
+  // already covered by the IsZero case above and converts to +0; any other
+  // negative input saturates to zero, or is poison when not saturating.
+  // Applied before the NaN case so that a negative NaN still produces the NaN
+  // encoding.
+  if (!DstHasSign) {
+    SDValue IsNegative =
+        DAG.getSetCC(dl, FPSetCCVT, FloatVal, FPZero, ISD::SETOLT);
+    SDValue NegResult = Saturate ? Zero : DAG.getPOISON(IntVT);
----------------
arsenm wrote:

Weird to pass poison to select in some case, these probably should be separate paths 

https://github.com/llvm/llvm-project/pull/216387


More information about the llvm-commits mailing list