[PATCH] D133955: [AArch64][CostModel] Add cost for v4f64 v4f32 extend/truncate operations when using fixed vectors over SVE

Dinar Temirbulatov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 15 09:42:04 PDT 2022


dtemirbulatov created this revision.
dtemirbulatov added reviewers: paulwalker-arm, peterwaller-arm, dmgreen, bsmith.
Herald added subscribers: ctetreau, hiraditya, kristof.beyls, tschuett.
Herald added a project: All.
dtemirbulatov requested review of this revision.
Herald added a project: LLVM.

Looks like AArch64 missing float pointer costs for v4f64 v4f32 extend/truncate operations when we want to use fixed vector types over SVE operations.


https://reviews.llvm.org/D133955

Files:
  llvm/lib/Target/AArch64/AArch64ISelLowering.h
  llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp


Index: llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
===================================================================
--- llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
+++ llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
@@ -1893,6 +1893,20 @@
             FP16Tbl, ISD, DstTy.getSimpleVT(), SrcTy.getSimpleVT()))
       return AdjustCost(Entry->Cost);
 
+  static const TypeConversionCostTblEntry SVEFixed[] = {
+      // Truncate from v4f64 to v4f32.
+      {ISD::FP_ROUND, MVT::v4f32, MVT::v4f64, 3},
+      // Extend from v4f32 to v4f64.
+      {ISD::FP_EXTEND, MVT::v4f64, MVT::v4f32, 2},
+  };
+
+  if (ST->hasSVE() &&
+      (getTLI()->useSVEForFixedLengthVectorVT(SrcTy.getSimpleVT()) ||
+       getTLI()->useSVEForFixedLengthVectorVT(DstTy.getSimpleVT())))
+    if (const auto *Entry = ConvertCostTableLookup(
+            SVEFixed, ISD, DstTy.getSimpleVT(), SrcTy.getSimpleVT()))
+      return AdjustCost(Entry->Cost);
+
   return AdjustCost(
       BaseT::getCastInstrCost(Opcode, Dst, Src, CCH, CostKind, I));
 }
Index: llvm/lib/Target/AArch64/AArch64ISelLowering.h
===================================================================
--- llvm/lib/Target/AArch64/AArch64ISelLowering.h
+++ llvm/lib/Target/AArch64/AArch64ISelLowering.h
@@ -868,6 +868,11 @@
 
   bool shouldExpandGetActiveLaneMask(EVT VT, EVT OpVT) const override;
 
+  // Normally SVE is only used for byte size vectors that do not fit within a
+  // NEON vector. This changes when OverrideNEON is true, allowing SVE to be
+  // used for 64bit and 128bit vectors as well.
+  bool useSVEForFixedLengthVectorVT(EVT VT, bool OverrideNEON = false) const;
+
 private:
   /// Keep a pointer to the AArch64Subtarget around so that we can
   /// make the right decision when generating code for different targets.
@@ -1141,11 +1146,6 @@
 
   bool isTargetCanonicalConstantNode(SDValue Op) const override;
 
-  // Normally SVE is only used for byte size vectors that do not fit within a
-  // NEON vector. This changes when OverrideNEON is true, allowing SVE to be
-  // used for 64bit and 128bit vectors as well.
-  bool useSVEForFixedLengthVectorVT(EVT VT, bool OverrideNEON = false) const;
-
   // With the exception of data-predicate transitions, no instructions are
   // required to cast between legal scalable vector types. However:
   //  1. Packed and unpacked types have different bit lengths, meaning BITCAST


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133955.460443.patch
Type: text/x-patch
Size: 2415 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220915/15e4ea34/attachment.bin>


More information about the llvm-commits mailing list