[llvm] [AArch64][SDAG] Lower f16->s16 FP_TO_INT_SAT to *v1f16 (PR #154822)

David Green via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 21 12:00:49 PDT 2025


================
@@ -4912,6 +4912,24 @@ SDValue AArch64TargetLowering::LowerFP_TO_INT_SAT(SDValue Op,
   if (DstWidth < SatWidth)
     return SDValue();
 
+  if (SrcVT == MVT::f16 && SatVT == MVT::i16 && DstVT == MVT::i32) {
+    auto Opcode = (Op.getOpcode() == ISD::FP_TO_SINT_SAT)
+                      ? AArch64::FCVTZSv1f16
+                      : AArch64::FCVTZUv1f16;
+    auto Cvt = SDValue(DAG.getMachineNode(Opcode, DL, MVT::f16, SrcVal), 0);
----------------
davemgreen wrote:

We try to avoid machine nodes at this level - it is like a layering violation. Ideally they should only be generated later. Can we add a new AArch64ISD node for it?
Also it is preferred to only use auto where the type is obvious.

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


More information about the llvm-commits mailing list