[llvm] [AArch64][SVE] Use SVE for scalar FP converts in streaming[-compatible] functions (PR #112564)
Paul Walker via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 24 05:59:12 PDT 2024
================
@@ -18929,13 +18929,67 @@ static SDValue performVectorCompareAndMaskUnaryOpCombine(SDNode *N,
return SDValue();
}
+static bool
+shouldUseSVEForScalarFPConversion(SDNode *N,
+ const AArch64Subtarget *Subtarget) {
+ auto isSupportedType = [](EVT VT) {
+ if (!VT.isSimple())
+ return false;
+ // There are SVE instructions that can convert to/from all pairs of these
+ // int and float types. Note: We don't bother with i8 or i16 as those are
+ // illegal types for scalars.
+ return is_contained({MVT::i32, MVT::i64, MVT::f16, MVT::f32, MVT::f64},
+ VT.getSimpleVT().SimpleTy);
+ };
+ // If we are in a streaming[-compatible] function, use SVE for scalar FP <->
+ // INT conversions as this can help avoid movs between GPRs and FPRs, which
+ // could be quite expensive.
+ return !N->isStrictFPOpcode() && Subtarget->isSVEorStreamingSVEAvailable() &&
+ (Subtarget->isStreaming() || Subtarget->isStreamingCompatible()) &&
+ isSupportedType(N->getValueType(0)) &&
+ isSupportedType(N->getOperand(0).getValueType());
+}
+
+/// Replaces a scalar FP <-> INT conversion with an SVE (scalable) one, wrapped
+/// with an insert and extract.
+static SDValue replaceScalarFPConversionWithSVE(SDNode *N, SelectionDAG &DAG) {
+ assert(!N->isStrictFPOpcode() && "strict fp ops not supported");
+ SDValue SrcVal = N->getOperand(0);
----------------
paulwalker-arm wrote:
I'd recommend delaying the combine until at least after type legalisation (e.g. isBeforeLegalizeOps()) because that gives time to remove the original code entirely and limits the combination of types you need to worry about, which might remove the need for, or at least simplify, `isSupportedType`.
https://github.com/llvm/llvm-project/pull/112564
More information about the llvm-commits
mailing list