91 lines · plain
1; RUN: not opt -passes=verify -S < %s 2>&1 >/dev/null | FileCheck %s2 3;4; Test that extractions/insertion indices are validated.5;6 7; CHECK: vector_extract index must be a constant multiple of the result type's known minimum vector length.8define <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)10 ret <4 x i32> %111}12 13; CHECK: vector_insert index must be a constant multiple of the subvector's known minimum vector length.14define <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)16 ret <8 x i32> %117}18 19;20; Test that extractions/insertion element types are validated.21;22 23; CHECK: vector_extract result must have the same element type as the input vector.24define <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> %retval27}28 29; CHECK: vector_insert parameters must have the same element type.30define <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> %retval33}34 35;36; Test that extractions/insertions which 'overrun' are captured.37;38 39; CHECK: vector_extract would overrun.40define <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)42 ret <3 x i32> %143}44 45; CHECK: vector_extract would overrun.46define <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> %149}50 51; We cannot statically check whether or not an extraction of a fixed vector52; from a scalable vector would overrun, because we can't compare the sizes of53; the two. Therefore, this function should not raise verifier errors.54; CHECK-NOT: vector_extract55define <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)57 ret <3 x i32> %158}59 60; CHECK: subvector operand of vector_insert would overrun the vector being inserted into.61define <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)63 ret <8 x i32> %164}65 66; CHECK: subvector operand of vector_insert would overrun the vector being inserted into.67define <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> %170}71 72; We cannot statically check whether or not an insertion of a fixed vector into73; a scalable vector would overrun, because we can't compare the sizes of the74; two. Therefore, this function should not raise verifier errors.75; CHECK-NOT: vector_insert76define <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> %179}80 81declare <vscale x 3 x i32> @llvm.vector.extract.nxv8i32.nxv3i32(<vscale x 8 x i32>, i64)82declare <vscale x 8 x i32> @llvm.vector.insert.nxv8i32.nxv3i32(<vscale x 8 x i32>, <vscale x 3 x i32>, i64)83declare <vscale x 8 x i32> @llvm.vector.insert.nxv8i32.v3i32(<vscale x 8 x i32>, <3 x i32>, i64)84declare <3 x i32> @llvm.vector.extract.nxv8i32.v3i32(<vscale x 8 x i32>, i64)85declare <3 x i32> @llvm.vector.extract.v8i32.v3i32(<8 x i32>, i64)86declare <4 x i32> @llvm.vector.extract.v4i32.v8i32(<8 x i32>, i64)87declare <8 x i32> @llvm.vector.insert.v8i32.v3i32(<8 x i32>, <3 x i32>, i64)88declare <8 x i32> @llvm.vector.insert.v8i32.v4i32(<8 x i32>, <4 x i32>, i64)89declare <16 x i16> @llvm.vector.extract.v16i16.nxv16i8(<vscale x 16 x i8>, i64)90declare <vscale x 16 x i8> @llvm.vector.insert.nxv16i8.v4i16(<vscale x 16 x i8>, <4 x i16>, i64)91