1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 04:02:41 +01:00
llvm-mirror/test/Verifier/stepvector-intrinsic.ll
David Sherwood 42a72164a2 [IR][SVE] Add new llvm.experimental.stepvector intrinsic
This patch adds a new llvm.experimental.stepvector intrinsic,
which takes no arguments and returns a linear integer sequence of
values of the form <0, 1, ...>. It is primarily intended for
scalable vectors, although it will work for fixed width vectors
too. It is intended that later patches will make use of this
new intrinsic when vectorising induction variables, currently only
supported for fixed width. I've added a new CreateStepVector
method to the IRBuilder, which will generate a call to this
intrinsic for scalable vectors and fall back on creating a
ConstantVector for fixed width.

For scalable vectors this intrinsic is lowered to a new ISD node
called STEP_VECTOR, which takes a single constant integer argument
as the step. During lowering this argument is set to a value of 1.
The reason for this additional argument at the codegen level is
because in future patches we will introduce various generic DAG
combines such as

  mul step_vector(1), 2 -> step_vector(2)
  add step_vector(1), step_vector(1) -> step_vector(2)
  shl step_vector(1), 1 -> step_vector(2)
  etc.

that encourage a canonical format for all targets. This hopefully
means all other targets supporting scalable vectors can benefit
from this too.

I've added cost model tests for both fixed width and scalable
vectors:

  llvm/test/Analysis/CostModel/AArch64/neon-stepvector.ll
  llvm/test/Analysis/CostModel/AArch64/sve-stepvector.ll

as well as codegen lowering tests for fixed width and scalable
vectors:

  llvm/test/CodeGen/AArch64/neon-stepvector.ll
  llvm/test/CodeGen/AArch64/sve-stepvector.ll

See this thread for discussion of the intrinsic:
https://lists.llvm.org/pipermail/llvm-dev/2021-January/147943.html
2021-03-23 10:43:35 +00:00

30 lines
1.0 KiB
LLVM

; RUN: not opt -S -verify < %s 2>&1 | FileCheck %s
; Reject stepvector intrinsics that return a scalar
define i32 @stepvector_i32() {
; CHECK: Intrinsic has incorrect return type!
%1 = call i32 @llvm.experimental.stepvector.i32()
ret i32 %1
}
; 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
%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()