[PATCH] D91260: [AArch64] Add check for widening instruction for SVE.

Caroline via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 11 07:04:46 PST 2020


CarolineConcatto created this revision.
Herald added subscribers: llvm-commits, hiraditya, kristof.beyls, tschuett.
Herald added a reviewer: rengolin.
Herald added a project: LLVM.
CarolineConcatto requested review of this revision.

This patch fixes the function isWideningInstruction for scalable vectors.
Now the cost model can check the widening pattern for SVE.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91260

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


Index: llvm/test/Analysis/CostModel/AArch64/sve-widening-instruction.ll
===================================================================
--- /dev/null
+++ llvm/test/Analysis/CostModel/AArch64/sve-widening-instruction.ll
@@ -0,0 +1,17 @@
+; Checks if widening instructions works for SVE
+
+; RUN: opt  -cost-model -analyze -mtriple=aarch64--linux-gnu -mattr=+sve %s | FileCheck %s
+
+define <vscale x 4 x i32> @widening(<vscale x 16 x i8> %in, <vscale x 4 x i16> %in2) {
+
+; CHECK-LABEL: 'widening':
+; CHECK: Cost Model: Found an estimated cost of {{[0-9]+}} for instruction:   %in.bc = bitcast <vscale x 16 x i8> %in to <vscale x 4 x i32>
+; CHECK-NEXT: Cost Model: Found an estimated cost of {{[0-9]+}} for instruction:   %in2.ext = zext <vscale x 4 x i16> %in2 to <vscale x 4 x i32>
+; CHECK-NEXT: Cost Model: Found an estimated cost of {{[0-9]+}} for instruction:   %in.add = add <vscale x 4 x i32> %in.bc, %in2.ext
+; CHECK-NEXT: Cost Model: Found an estimated cost of {{[0-9]+}} for instruction:   ret <vscale x 4 x i32> %in.add
+
+  %in.bc = bitcast <vscale x 16 x i8> %in to <vscale x 4 x i32>
+  %in2.ext = zext <vscale x 4 x i16> %in2 to <vscale x 4 x i32>
+  %in.add = add <vscale x 4 x i32> %in.bc, %in2.ext
+  ret <vscale x 4 x i32> %in.add
+}
Index: llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
===================================================================
--- llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
+++ llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
@@ -240,8 +240,8 @@
   // A helper that returns a vector type from the given type. The number of
   // elements in type Ty determine the vector width.
   auto toVectorTy = [&](Type *ArgTy) {
-    return FixedVectorType::get(ArgTy->getScalarType(),
-                                cast<FixedVectorType>(DstTy)->getNumElements());
+    return VectorType::get(ArgTy->getScalarType(),
+                           cast<VectorType>(DstTy)->getElementCount());
   };
 
   // Exit early if DstTy is not a vector type whose elements are at least
@@ -290,8 +290,8 @@
     return false;
 
   // Get the total number of vector elements in the legalized types.
-  unsigned NumDstEls = DstTyL.first * DstTyL.second.getVectorNumElements();
-  unsigned NumSrcEls = SrcTyL.first * SrcTyL.second.getVectorNumElements();
+  unsigned NumDstEls = DstTyL.first * DstTyL.second.getVectorMinNumElements();
+  unsigned NumSrcEls = SrcTyL.first * SrcTyL.second.getVectorMinNumElements();
 
   // Return true if the legalized types have the same number of vector elements
   // and the destination element type size is twice that of the source type.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D91260.304508.patch
Type: text/x-patch
Size: 2633 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201111/5707b994/attachment.bin>


More information about the llvm-commits mailing list