[PATCH] D95598: [AArch64][SVE]Add cost model for broadcast shuffle

Caroline via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 29 07:46:48 PST 2021


CarolineConcatto updated this revision to Diff 320132.
CarolineConcatto marked 2 inline comments as done.
CarolineConcatto added a comment.

- simplify sve broadcast test


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95598/new/

https://reviews.llvm.org/D95598

Files:
  llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
  llvm/test/Analysis/CostModel/AArch64/sve-shuffle-broadcast.ll


Index: llvm/test/Analysis/CostModel/AArch64/sve-shuffle-broadcast.ll
===================================================================
--- /dev/null
+++ llvm/test/Analysis/CostModel/AArch64/sve-shuffle-broadcast.ll
@@ -0,0 +1,43 @@
+; Check getShuffleCost for SK_BroadCast with scalable vector
+
+; RUN: opt -cost-model -analyze -mtriple=aarch64--linux-gnu -mattr=sve  < %s 2>%t | FileCheck %s
+
+; RUN: FileCheck --check-prefix=WARN --allow-empty %s <%t
+
+; If this check fails please read test/CodeGen/AArch64/README for instructions on how to resolve it.
+; WARN-NOT: warning
+
+
+define void  @broadcast(<vscale x 32 x i8> %v) {
+; CHECK-LABEL: 'broadcast':
+; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction:   %zero = shufflevector <vscale x 16 x i8> undef, <vscale x 16 x i8> poison, <vscale x 16 x i32> zeroinitializer
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 2 for instruction:   %1 = shufflevector <vscale x 32 x i8> undef, <vscale x 32 x i8> poison, <vscale x 32 x i32> zeroinitializer
+; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction:   %2 = shufflevector <vscale x 8 x i16> undef, <vscale x 8 x i16> poison, <vscale x 8 x i32> zeroinitializer
+; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction:   %3 = shufflevector <vscale x 16 x i16> undef, <vscale x 16 x i16> poison, <vscale x 16 x i32> zeroinitializer
+; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction:   %4 = shufflevector <vscale x 4 x i32> undef, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer
+; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction:   %5 = shufflevector <vscale x 8 x i32> undef, <vscale x 8 x i32> poison, <vscale x 8 x i32> zeroinitializer
+; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction:   %6 = shufflevector <vscale x 2 x i64> undef, <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer
+; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction:   %7 = shufflevector <vscale x 4 x i64> undef, <vscale x 4 x i64> poison, <vscale x 4 x i32> zeroinitializer
+; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction:   %8 = shufflevector <vscale x 8 x half> undef, <vscale x 8 x half> poison, <vscale x 8 x i32> zeroinitializer
+; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction:   %9 = shufflevector <vscale x 16 x half> undef, <vscale x 16 x half> poison, <vscale x 16 x i32> zeroinitializer
+; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction:   %10 = shufflevector <vscale x 4 x float> undef, <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer
+; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction:   %11 = shufflevector <vscale x 8 x float> undef, <vscale x 8 x float> poison, <vscale x 8 x i32> zeroinitializer
+; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction:   %12 = shufflevector <vscale x 2 x double> undef, <vscale x 2 x double> poison, <vscale x 2 x i32> zeroinitializer
+; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction:   %13 = shufflevector <vscale x 4 x double> undef, <vscale x 4 x double> poison, <vscale x 4 x i32> zeroinitializer
+; CHECK-NETX: Cost Model: Found an estimated cost of 0 for instruction:   ret void
+  %zero = shufflevector <vscale x 16 x i8> undef, <vscale x 16 x i8> poison, <vscale x 16 x i32> zeroinitializer
+  %1 = shufflevector <vscale x 32 x i8> undef, <vscale x 32 x i8> poison, <vscale x 32 x i32> zeroinitializer
+  %2 = shufflevector <vscale x 8 x i16> undef, <vscale x 8 x i16> poison, <vscale x 8 x i32> zeroinitializer
+  %3 = shufflevector <vscale x 16 x i16> undef, <vscale x 16 x i16> poison, <vscale x 16 x i32> zeroinitializer
+  %4 = shufflevector <vscale x 4 x i32> undef, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer
+  %5 = shufflevector <vscale x 8 x i32> undef, <vscale x 8 x i32> poison, <vscale x 8 x i32> zeroinitializer
+  %6 = shufflevector <vscale x 2 x i64> undef, <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer
+  %7 = shufflevector <vscale x 4 x i64> undef, <vscale x 4 x i64> poison, <vscale x 4 x i32> zeroinitializer
+  %8 = shufflevector <vscale x 8 x half> undef, <vscale x 8 x half> poison, <vscale x 8 x i32> zeroinitializer
+  %9 = shufflevector <vscale x 16 x half> undef, <vscale x 16 x half> poison, <vscale x 16 x i32> zeroinitializer
+ %10 = shufflevector <vscale x 4 x float> undef, <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer
+  %11 = shufflevector <vscale x 8 x float> undef, <vscale x 8 x float> poison, <vscale x 8 x i32> zeroinitializer
+ %12 = shufflevector <vscale x 2 x double> undef, <vscale x 2 x double> poison, <vscale x 2 x i32> zeroinitializer
+ %13 = shufflevector <vscale x 4 x double> undef, <vscale x 4 x double> poison, <vscale x 4 x i32> zeroinitializer
+  ret void
+}
Index: llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
===================================================================
--- llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
+++ llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
@@ -1233,6 +1233,14 @@
       { TTI::SK_PermuteSingleSrc, MVT::v2f32, 1 }, // mov.
       { TTI::SK_PermuteSingleSrc, MVT::v4f32, 3 }, // perfectshuffle worst case.
       { TTI::SK_PermuteSingleSrc, MVT::v2f64, 1 }, // mov.
+      // Broadcast shuffle kinds for scalable vectors
+      { TTI::SK_Broadcast, MVT::nxv16i8,  1 },
+      { TTI::SK_Broadcast, MVT::nxv8i16,  1 },
+      { TTI::SK_Broadcast, MVT::nxv4i32,  1 },
+      { TTI::SK_Broadcast, MVT::nxv2i64,  1 },
+      { TTI::SK_Broadcast, MVT::nxv8f16,  1 },
+      { TTI::SK_Broadcast, MVT::nxv4f32,  1 },
+      { TTI::SK_Broadcast, MVT::nxv2f64,  1 },
     };
     std::pair<int, MVT> LT = TLI->getTypeLegalizationCost(DL, Tp);
     if (const auto *Entry = CostTableLookup(ShuffleTbl, Kind, LT.second))


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95598.320132.patch
Type: text/x-patch
Size: 5943 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210129/52af7910/attachment.bin>


More information about the llvm-commits mailing list