[llvm] [LLVM][CodeGen][SVE] Add lowering for bfloat strict-fp cast operators. (PR #223709)

Paul Walker via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 8 09:56:18 PDT 2026


================
@@ -5052,20 +5052,36 @@ SDValue AArch64TargetLowering::LowerFP_ROUND(SDValue Op,
         NaN = DAG.getNode(ISD::OR, DL, I32, Narrow, ImmV(0x400000));
     } else if (SrcVT == MVT::nxv2f64 &&
                (Subtarget->hasSVE2() || Subtarget->isStreamingSVEAvailable())) {
-      // Round to float without introducing rounding errors and try again.
-      SDValue Pg = getPredicateForVector(DAG, DL, MVT::nxv2f32);
-      Narrow = DAG.getNode(AArch64ISD::FCVTX_MERGE_PASSTHRU, DL, MVT::nxv2f32,
-                           Pg, SrcVal, DAG.getPOISON(MVT::nxv2f32));
-
-      SmallVector<SDValue, 3> NewOps;
+      // Split cast into two phases, using float as the intermediary.
+      SDVTList CvtF32VTs = IsStrict ? DAG.getVTList(MVT::nxv2f32, MVT::Other)
+                                    : DAG.getVTList(MVT::nxv2f32);
+
+      // Round to float without introducing rounding errors.
----------------
paulwalker-arm wrote:

Some precision is lost but enough is kept so that the second rounding operation is error free.
```
Rounding to Odd (aka Von Neumann rounding) permits a two-step conversion from double-precision to half-precision without incurring
intermediate rounding errors.
```
I don't fully understand it, but here I've just duplicated what we've already done for non-strict variants.

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


More information about the llvm-commits mailing list