1 ; RUN: not opt -verify -S < %s 2>&1 >/dev/null | FileCheck %s
4 ; Test that extractions/insertion indices are validated.
7 ; CHECK: experimental_vector_extract index must be a constant multiple of the result type's known minimum vector length.
8 define <4 x i32> @extract_idx_not_constant_multiple(<8 x i32> %vec) {
9 %1 = call <4 x i32> @llvm.experimental.vector.extract.v4i32.v8i32(<8 x i32> %vec, i64 1)
13 ; CHECK: experimental_vector_insert index must be a constant multiple of the subvector's known minimum vector length.
14 define <8 x i32> @insert_idx_not_constant_multiple(<8 x i32> %vec, <4 x i32> %subvec) {
15 %1 = call <8 x i32> @llvm.experimental.vector.insert.v8i32.v4i32(<8 x i32> %vec, <4 x i32> %subvec, i64 2)
20 ; Test that extractions/insertions which 'overrun' are captured.
23 ; CHECK: experimental_vector_extract would overrun.
24 define <3 x i32> @extract_overrun_fixed_fixed(<8 x i32> %vec) {
25 %1 = call <3 x i32> @llvm.experimental.vector.extract.v8i32.v3i32(<8 x i32> %vec, i64 6)
29 ; CHECK: experimental_vector_extract would overrun.
30 define <vscale x 3 x i32> @extract_overrun_scalable_scalable(<vscale x 8 x i32> %vec) {
31 %1 = call <vscale x 3 x i32> @llvm.experimental.vector.extract.nxv8i32.nxv3i32(<vscale x 8 x i32> %vec, i64 6)
32 ret <vscale x 3 x i32> %1
35 ; We cannot statically check whether or not an extraction of a fixed vector
36 ; from a scalable vector would overrun, because we can't compare the sizes of
37 ; the two. Therefore, this function should not raise verifier errors.
38 ; CHECK-NOT: experimental_vector_extract
39 define <3 x i32> @extract_overrun_scalable_fixed(<vscale x 8 x i32> %vec) {
40 %1 = call <3 x i32> @llvm.experimental.vector.extract.nxv8i32.v3i32(<vscale x 8 x i32> %vec, i64 6)
44 ; CHECK: subvector operand of experimental_vector_insert would overrun the vector being inserted into.
45 define <8 x i32> @insert_overrun_fixed_fixed(<8 x i32> %vec, <3 x i32> %subvec) {
46 %1 = call <8 x i32> @llvm.experimental.vector.insert.v8i32.v3i32(<8 x i32> %vec, <3 x i32> %subvec, i64 6)
50 ; CHECK: subvector operand of experimental_vector_insert would overrun the vector being inserted into.
51 define <vscale x 8 x i32> @insert_overrun_scalable_scalable(<vscale x 8 x i32> %vec, <vscale x 3 x i32> %subvec) {
52 %1 = call <vscale x 8 x i32> @llvm.experimental.vector.insert.nxv8i32.nxv3i32(<vscale x 8 x i32> %vec, <vscale x 3 x i32> %subvec, i64 6)
53 ret <vscale x 8 x i32> %1
56 ; We cannot statically check whether or not an insertion of a fixed vector into
57 ; a scalable vector would overrun, because we can't compare the sizes of the
58 ; two. Therefore, this function should not raise verifier errors.
59 ; CHECK-NOT: experimental_vector_insert
60 define <vscale x 8 x i32> @insert_overrun_scalable_fixed(<vscale x 8 x i32> %vec, <3 x i32> %subvec) {
61 %1 = call <vscale x 8 x i32> @llvm.experimental.vector.insert.nxv8i32.v3i32(<vscale x 8 x i32> %vec, <3 x i32> %subvec, i64 6)
62 ret <vscale x 8 x i32> %1
65 declare <vscale x 3 x i32> @llvm.experimental.vector.extract.nxv8i32.nxv3i32(<vscale x 8 x i32>, i64)
66 declare <vscale x 8 x i32> @llvm.experimental.vector.insert.nxv8i32.nxv3i32(<vscale x 8 x i32>, <vscale x 3 x i32>, i64)
67 declare <vscale x 8 x i32> @llvm.experimental.vector.insert.nxv8i32.v3i32(<vscale x 8 x i32>, <3 x i32>, i64)
68 declare <3 x i32> @llvm.experimental.vector.extract.nxv8i32.v3i32(<vscale x 8 x i32>, i64)
69 declare <3 x i32> @llvm.experimental.vector.extract.v8i32.v3i32(<8 x i32>, i64)
70 declare <4 x i32> @llvm.experimental.vector.extract.v4i32.v8i32(<8 x i32>, i64)
71 declare <8 x i32> @llvm.experimental.vector.insert.v8i32.v3i32(<8 x i32>, <3 x i32>, i64)
72 declare <8 x i32> @llvm.experimental.vector.insert.v8i32.v4i32(<8 x i32>, <4 x i32>, i64)