[PATCH] D113655: [IR] Allow all integer types for stepvector intrinsic

David Sherwood via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 11 01:56:45 PST 2021


david-arm created this revision.
david-arm added reviewers: sdesmalen, c-rhodes, peterwaller-arm, RosieSumpter, efriedma.
Herald added subscribers: ctetreau, dexonsmith, jdoerfert, hiraditya, kristof.beyls.
david-arm requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This patch changes the Verifier and LangRef to permit any integer
element types when creating the experimental stepvector intrinsic.

When compiling some SPEC benchmark code the vectoriser was attempting
to vectorise loops with unusual integer types, i.e. i3, and create
corresponding vector induction variables. For scalable vectors this
requires generating a stepvector intrisic for vectors with i3 element
types.

Tests added here:

  CodeGen/AArch64/sve-stepvector.ll


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113655

Files:
  llvm/docs/LangRef.rst
  llvm/lib/IR/Verifier.cpp
  llvm/test/CodeGen/AArch64/sve-stepvector.ll
  llvm/test/Verifier/stepvector-intrinsic.ll


Index: llvm/test/Verifier/stepvector-intrinsic.ll
===================================================================
--- llvm/test/Verifier/stepvector-intrinsic.ll
+++ llvm/test/Verifier/stepvector-intrinsic.ll
@@ -11,19 +11,10 @@
 ; Reject vectors with non-integer elements
 
 define <vscale x 4 x float> @stepvector_float() {
-; CHECK: experimental_stepvector only supported for vectors of integers with a bitwidth of at least 8
+; CHECK: experimental_stepvector only supported for vectors of integers.
   %1 = call <vscale x 4 x float> @llvm.experimental.stepvector.nxv4f32()
   ret <vscale x 4 x float> %1
 }
 
-; Reject vectors of integers less than 8 bits in width
-
-define <vscale x 16 x i1> @stepvector_i1() {
-; CHECK: experimental_stepvector only supported for vectors of integers with a bitwidth of at least 8
-  %1 = call <vscale x 16 x i1> @llvm.experimental.stepvector.nxv16i1()
-  ret <vscale x 16 x i1> %1
-}
-
 declare i32 @llvm.experimental.stepvector.i32()
 declare <vscale x 4 x float> @llvm.experimental.stepvector.nxv4f32()
-declare <vscale x 16 x i1> @llvm.experimental.stepvector.nxv16i1()
Index: llvm/test/CodeGen/AArch64/sve-stepvector.ll
===================================================================
--- llvm/test/CodeGen/AArch64/sve-stepvector.ll
+++ llvm/test/CodeGen/AArch64/sve-stepvector.ll
@@ -43,6 +43,27 @@
   ret <vscale x 16 x i8> %0
 }
 
+; Integer element types that need promoting
+define <vscale x 2 x i3> @stepvector_nxv2i3() {
+; CHECK-LABEL: stepvector_nxv2i3:
+; CHECK:       // %bb.0: // %entry
+; CHECK-NEXT:    index z0.d, #0, #1
+; CHECK-NEXT:    ret
+entry:
+  %0 = call <vscale x 2 x i3> @llvm.experimental.stepvector.nxv2i3()
+  ret <vscale x 2 x i3> %0
+}
+
+define <vscale x 4 x i31> @stepvector_nxv4i31() {
+; CHECK-LABEL: stepvector_nxv4i31:
+; CHECK:       // %bb.0: // %entry
+; CHECK-NEXT:    index z0.s, #0, #1
+; CHECK-NEXT:    ret
+entry:
+  %0 = call <vscale x 4 x i31> @llvm.experimental.stepvector.nxv4i31()
+  ret <vscale x 4 x i31> %0
+}
+
 ; ILLEGAL INTEGER TYPES
 
 define <vscale x 4 x i64> @stepvector_nxv4i64() {
@@ -405,6 +426,8 @@
 declare <vscale x 4 x i32> @llvm.experimental.stepvector.nxv4i32()
 declare <vscale x 8 x i16> @llvm.experimental.stepvector.nxv8i16()
 declare <vscale x 16 x i8> @llvm.experimental.stepvector.nxv16i8()
+declare <vscale x 2 x i3> @llvm.experimental.stepvector.nxv2i3()
+declare <vscale x 4 x i31> @llvm.experimental.stepvector.nxv4i31()
 
 declare <vscale x 4 x i64> @llvm.experimental.stepvector.nxv4i64()
 declare <vscale x 16 x i32> @llvm.experimental.stepvector.nxv16i32()
Index: llvm/lib/IR/Verifier.cpp
===================================================================
--- llvm/lib/IR/Verifier.cpp
+++ llvm/lib/IR/Verifier.cpp
@@ -5316,10 +5316,8 @@
   }
   case Intrinsic::experimental_stepvector: {
     VectorType *VecTy = dyn_cast<VectorType>(Call.getType());
-    Assert(VecTy && VecTy->getScalarType()->isIntegerTy() &&
-               VecTy->getScalarSizeInBits() >= 8,
-           "experimental_stepvector only supported for vectors of integers "
-           "with a bitwidth of at least 8.",
+    Assert(VecTy && VecTy->getScalarType()->isIntegerTy(),
+           "experimental_stepvector only supported for vectors of integers.",
            &Call);
     break;
   }
Index: llvm/docs/LangRef.rst
===================================================================
--- llvm/docs/LangRef.rst
+++ llvm/docs/LangRef.rst
@@ -17223,9 +17223,8 @@
 The '``llvm.experimental.stepvector``' intrinsics are used to create vectors
 of integers whose elements contain a linear sequence of values starting from 0
 with a step of 1.  This experimental intrinsic can only be used for vectors
-with integer elements that are at least 8 bits in size. If the sequence value
-exceeds the allowed limit for the element type then the result for that lane is
-undefined.
+with integer elements. If the sequence value exceeds the allowed limit for
+the element type then the result for that lane is undefined.
 
 These intrinsics work for both fixed and scalable vectors. While this intrinsic
 is marked as experimental, the recommended way to express this operation for


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113655.386452.patch
Type: text/x-patch
Size: 4178 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211111/0c32230a/attachment.bin>


More information about the llvm-commits mailing list