[llvm] [AArch64][SVE] Use SVE for scalar FP converts in streaming[-compatible] functions (1/n) (PR #118505)

Benjamin Maxwell via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 16 06:41:14 PST 2024


================
@@ -18989,13 +18989,88 @@ static SDValue performVectorCompareAndMaskUnaryOpCombine(SDNode *N,
   return SDValue();
 }
 
+/// Tries to replace scalar FP <-> INT conversions with SVE in streaming
+/// functions, this can help to reduce the number of fmovs to/from GPRs.
+static SDValue
+tryToReplaceScalarFPConversionWithSVE(SDNode *N, SelectionDAG &DAG,
+                                      TargetLowering::DAGCombinerInfo &DCI,
+                                      const AArch64Subtarget *Subtarget) {
+  if (N->isStrictFPOpcode())
+    return SDValue();
+
+  if (DCI.isBeforeLegalizeOps())
+    return SDValue();
+
+  if (!Subtarget->isSVEorStreamingSVEAvailable() ||
+      (!Subtarget->isStreaming() && !Subtarget->isStreamingCompatible()))
+    return SDValue();
+
+  auto isSupportedType = [](EVT VT) {
+    return VT != MVT::bf16 && VT != MVT::f128;
+  };
+
+  if (!isSupportedType(N->getValueType(0)) ||
+      !isSupportedType(N->getOperand(0).getValueType()))
+    return SDValue();
+
+  // Look through fp_extends to avoid extra fcvts.
+  SDValue SrcVal = N->getOperand(0);
+  if (SrcVal->getOpcode() == ISD::FP_EXTEND &&
+      isSupportedType(SrcVal->getOperand(0).getValueType()))
+    SrcVal = SrcVal->getOperand(0);
----------------
MacDue wrote:

Removed this :+1: 

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


More information about the llvm-commits mailing list