1 ; RUN: not opt -passes=verify -S < %s 2>&1 >/dev/null | FileCheck %s
4 ; Test that extractions/insertion indices are validated.
7 ; CHECK: 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.vector.extract.v4i32.v8i32(<8 x i32> %vec, i64 1)
13 ; CHECK: 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.vector.insert.v8i32.v4i32(<8 x i32> %vec, <4 x i32> %subvec, i64 2)
20 ; Test that extractions/insertion element types are validated.
23 ; CHECK: vector_extract result must have the same element type as the input vector.
24 define <16 x i16> @extract_invalid_mismatched_element_types(<vscale x 16 x i8> %vec) nounwind {
25 %retval = call <16 x i16> @llvm.vector.extract.v16i16.nxv16i8(<vscale x 16 x i8> %vec, i64 0)
26 ret <16 x i16> %retval
29 ; CHECK: vector_insert parameters must have the same element type.
30 define <vscale x 16 x i8> @insert_invalid_mismatched_element_types(<vscale x 16 x i8> %vec, <4 x i16> %subvec) nounwind {
31 %retval = call <vscale x 16 x i8> @llvm.vector.insert.nxv16i8.v4i16(<vscale x 16 x i8> %vec, <4 x i16> %subvec, i64 0)
32 ret <vscale x 16 x i8> %retval
36 ; Test that extractions/insertions which 'overrun' are captured.
39 ; CHECK: vector_extract would overrun.
40 define <3 x i32> @extract_overrun_fixed_fixed(<8 x i32> %vec) {
41 %1 = call <3 x i32> @llvm.vector.extract.v8i32.v3i32(<8 x i32> %vec, i64 6)
45 ; CHECK: vector_extract would overrun.
46 define <vscale x 3 x i32> @extract_overrun_scalable_scalable(<vscale x 8 x i32> %vec) {
47 %1 = call <vscale x 3 x i32> @llvm.vector.extract.nxv8i32.nxv3i32(<vscale x 8 x i32> %vec, i64 6)
48 ret <vscale x 3 x i32> %1
51 ; We cannot statically check whether or not an extraction of a fixed vector
52 ; from a scalable vector would overrun, because we can't compare the sizes of
53 ; the two. Therefore, this function should not raise verifier errors.
54 ; CHECK-NOT: vector_extract
55 define <3 x i32> @extract_overrun_scalable_fixed(<vscale x 8 x i32> %vec) {
56 %1 = call <3 x i32> @llvm.vector.extract.nxv8i32.v3i32(<vscale x 8 x i32> %vec, i64 6)
60 ; CHECK: subvector operand of vector_insert would overrun the vector being inserted into.
61 define <8 x i32> @insert_overrun_fixed_fixed(<8 x i32> %vec, <3 x i32> %subvec) {
62 %1 = call <8 x i32> @llvm.vector.insert.v8i32.v3i32(<8 x i32> %vec, <3 x i32> %subvec, i64 6)
66 ; CHECK: subvector operand of vector_insert would overrun the vector being inserted into.
67 define <vscale x 8 x i32> @insert_overrun_scalable_scalable(<vscale x 8 x i32> %vec, <vscale x 3 x i32> %subvec) {
68 %1 = call <vscale x 8 x i32> @llvm.vector.insert.nxv8i32.nxv3i32(<vscale x 8 x i32> %vec, <vscale x 3 x i32> %subvec, i64 6)
69 ret <vscale x 8 x i32> %1
72 ; We cannot statically check whether or not an insertion of a fixed vector into
73 ; a scalable vector would overrun, because we can't compare the sizes of the
74 ; two. Therefore, this function should not raise verifier errors.
75 ; CHECK-NOT: vector_insert
76 define <vscale x 8 x i32> @insert_overrun_scalable_fixed(<vscale x 8 x i32> %vec, <3 x i32> %subvec) {
77 %1 = call <vscale x 8 x i32> @llvm.vector.insert.nxv8i32.v3i32(<vscale x 8 x i32> %vec, <3 x i32> %subvec, i64 6)
78 ret <vscale x 8 x i32> %1
81 declare <vscale x 3 x i32> @llvm.vector.extract.nxv8i32.nxv3i32(<vscale x 8 x i32>, i64)
82 declare <vscale x 8 x i32> @llvm.vector.insert.nxv8i32.nxv3i32(<vscale x 8 x i32>, <vscale x 3 x i32>, i64)
83 declare <vscale x 8 x i32> @llvm.vector.insert.nxv8i32.v3i32(<vscale x 8 x i32>, <3 x i32>, i64)
84 declare <3 x i32> @llvm.vector.extract.nxv8i32.v3i32(<vscale x 8 x i32>, i64)
85 declare <3 x i32> @llvm.vector.extract.v8i32.v3i32(<8 x i32>, i64)
86 declare <4 x i32> @llvm.vector.extract.v4i32.v8i32(<8 x i32>, i64)
87 declare <8 x i32> @llvm.vector.insert.v8i32.v3i32(<8 x i32>, <3 x i32>, i64)
88 declare <8 x i32> @llvm.vector.insert.v8i32.v4i32(<8 x i32>, <4 x i32>, i64)
89 declare <16 x i16> @llvm.vector.extract.v16i16.nxv16i8(<vscale x 16 x i8>, i64)
90 declare <vscale x 16 x i8> @llvm.vector.insert.nxv16i8.v4i16(<vscale x 16 x i8>, <4 x i16>, i64)