| 1 |
// RUN: cir-opt %s -verify-diagnostics -split-input-file |
| 2 |
|
| 3 |
!s32i = !cir.int<s, 32> |
| 4 |
|
| 5 |
module { |
| 6 |
|
| 7 |
// expected-error @below {{failed to verify 'element_type'}} |
| 8 |
cir.global external @vec_b = #cir.zero : !cir.vector<4 x !cir.array<!s32i x 10>> |
| 9 |
|
| 10 |
} |
| 11 |
|
| 12 |
// ----- |
| 13 |
|
| 14 |
cir.func @invalid_scalable_vec_syntax() { |
| 15 |
// expected-error@+2 {{missing closing `]` for scalable dim size}} |
| 16 |
// expected-error @below {{expected ']'}} |
| 17 |
%3 = cir.alloca !cir.vector<[1 x] !s32i>, !cir.ptr<!cir.vector<[1] x !s32i>> |
| 18 |
cir.return |
| 19 |
|
| 20 |
} |
| 21 |
|
| 22 |
// ----- |
| 23 |
|
| 24 |
!s32i = !cir.int<s, 32> |
| 25 |
!s64i = !cir.int<s, 64> |
| 26 |
|
| 27 |
module { |
| 28 |
cir.func @vector_shuffle_invalid_element_type() { |
| 29 |
%1 = cir.const #cir.int<1> : !s32i |
| 30 |
%2 = cir.const #cir.int<2> : !s32i |
| 31 |
%3 = cir.const #cir.int<3> : !s32i |
| 32 |
%4 = cir.const #cir.int<4> : !s32i |
| 33 |
%vec_1 = cir.vec.create(%1, %2, %3, %4 : !s32i, !s32i, !s32i, !s32i) : !cir.vector<4 x !s32i> |
| 34 |
%vec_2 = cir.vec.create(%1, %2, %3, %4 : !s32i, !s32i, !s32i, !s32i) : !cir.vector<4 x !s32i> |
| 35 |
// expected-error @below {{element types of '!cir.vector<4 x !cir.int<s, 32>>' and '!cir.vector<4 x !cir.int<s, 64>>' don't match}} |
| 36 |
%new_vec = cir.vec.shuffle(%vec_1, %vec_2 : !cir.vector<4 x !s32i>) [#cir.int<7> : !s64i, #cir.int<5> : !s64i, #cir.int<3> : !s64i, #cir.int<1> : !s64i] : !cir.vector<4 x !s64i> |
| 37 |
cir.return |
| 38 |
} |
| 39 |
} |
| 40 |
|
| 41 |
// ----- |
| 42 |
|
| 43 |
!s32i = !cir.int<s, 32> |
| 44 |
!s64i = !cir.int<s, 64> |
| 45 |
|
| 46 |
module { |
| 47 |
cir.func @vector_shuffle_different_number_of_elements() { |
| 48 |
%1 = cir.const #cir.int<1> : !s32i |
| 49 |
%2 = cir.const #cir.int<2> : !s32i |
| 50 |
%3 = cir.const #cir.int<3> : !s32i |
| 51 |
%4 = cir.const #cir.int<4> : !s32i |
| 52 |
%vec_1 = cir.vec.create(%1, %2, %3, %4 : !s32i, !s32i, !s32i, !s32i) : !cir.vector<4 x !s32i> |
| 53 |
%vec_2 = cir.vec.create(%1, %2, %3, %4 : !s32i, !s32i, !s32i, !s32i) : !cir.vector<4 x !s32i> |
| 54 |
// expected-error @below {{the number of elements in [#cir.int<7> : !cir.int<s, 64>, #cir.int<5> : !cir.int<s, 64>, #cir.int<3> : !cir.int<s, 64>] and '!cir.vector<4 x !cir.int<s, 64>>' don't match}} |
| 55 |
%new_vec = cir.vec.shuffle(%vec_1, %vec_2 : !cir.vector<4 x !s32i>) [#cir.int<7> : !s64i, #cir.int<5> : !s64i, #cir.int<3> : !s64i] : !cir.vector<4 x !s64i> |
| 56 |
cir.return |
| 57 |
} |
| 58 |
} |
| 59 |
|
| 60 |
// ----- |
| 61 |
|
| 62 |
!s32i = !cir.int<s, 32> |
| 63 |
|
| 64 |
module { |
| 65 |
cir.func @vector_create_different_size() { |
| 66 |
%1 = cir.const #cir.int<1> : !s32i |
| 67 |
%2 = cir.const #cir.int<2> : !s32i |
| 68 |
%3 = cir.const #cir.int<3> : !s32i |
| 69 |
%4 = cir.const #cir.int<4> : !s32i |
| 70 |
|
| 71 |
// expected-error @below {{operand count of 4 doesn't match vector type '!cir.vector<8 x !cir.int<s, 32>>' element count of 8}} |
| 72 |
%5 = cir.vec.create(%1, %2, %3, %4 : !s32i, !s32i, !s32i, !s32i) : !cir.vector<8 x !s32i> |
| 73 |
cir.return |
| 74 |
} |
| 75 |
} |
| 76 |
|
| 77 |
// ----- |
| 78 |
|
| 79 |
!s32i = !cir.int<s, 32> |
| 80 |
!s64i = !cir.int<s, 64> |
| 81 |
|
| 82 |
module { |
| 83 |
cir.func @vector_create_different_type_size() { |
| 84 |
%1 = cir.const #cir.int<1> : !s32i |
| 85 |
%2 = cir.const #cir.int<2> : !s32i |
| 86 |
%3 = cir.const #cir.int<3> : !s32i |
| 87 |
%4 = cir.const #cir.int<4> : !s64i |
| 88 |
|
| 89 |
// expected-error @below {{operand type '!cir.int<s, 64>' doesn't match vector element type '!cir.int<s, 32>'}} |
| 90 |
%5 = cir.vec.create(%1, %2, %3, %4 : !s32i, !s32i, !s32i, !s64i) : !cir.vector<4 x !s32i> |
| 91 |
cir.return |
| 92 |
} |
| 93 |
} |
| 94 |
|
| 95 |
// ----- |
| 96 |
|
| 97 |
!s32i = !cir.int<s, 32> |
| 98 |
|
| 99 |
module { |
| 100 |
cir.func @vector_shift_invalid_result_type() { |
| 101 |
%1 = cir.const #cir.int<1> : !s32i |
| 102 |
%2 = cir.const #cir.int<2> : !s32i |
| 103 |
%3 = cir.const #cir.int<3> : !s32i |
| 104 |
%4 = cir.const #cir.int<4> : !s32i |
| 105 |
%5 = cir.vec.create(%1, %2, %3, %4 : !s32i, !s32i, !s32i, !s32i) : !cir.vector<4 x !s32i> |
| 106 |
%6 = cir.vec.create(%1, %2, %3, %4 : !s32i, !s32i, !s32i, !s32i) : !cir.vector<4 x !s32i> |
| 107 |
// expected-error @below {{the type of the result must be a vector if it is vector shift}} |
| 108 |
%7 = cir.shift(left, %5 : !cir.vector<4 x !s32i>, %6 : !cir.vector<4 x !s32i>) -> !s32i |
| 109 |
cir.return |
| 110 |
} |
| 111 |
} |
| 112 |
|
| 113 |
// ----- |
| 114 |
|
| 115 |
!s32i = !cir.int<s, 32> |
| 116 |
!s64i = !cir.int<s, 64> |
| 117 |
|
| 118 |
module { |
| 119 |
cir.func @vector_shuffle_dynamic_different_number_of_elements() { |
| 120 |
%1 = cir.const #cir.int<1> : !s32i |
| 121 |
%2 = cir.const #cir.int<2> : !s32i |
| 122 |
%3 = cir.const #cir.int<3> : !s32i |
| 123 |
%4 = cir.const #cir.int<4> : !s32i |
| 124 |
%vec = cir.vec.create(%1, %2, %3, %4 : !s32i, !s32i, !s32i, !s32i) : !cir.vector<4 x !s32i> |
| 125 |
%indices = cir.vec.create(%1, %2 : !s32i, !s32i) : !cir.vector<2 x !s32i> |
| 126 |
|
| 127 |
// expected-error @below {{the number of elements in '!cir.vector<4 x !cir.int<s, 32>>' and '!cir.vector<2 x !cir.int<s, 32>>' don't match}} |
| 128 |
%new_vec = cir.vec.shuffle.dynamic %vec : !cir.vector<4 x !s32i>, %indices : !cir.vector<2 x !s32i> |
| 129 |
cir.return |
| 130 |
} |
| 131 |
} |
| 132 |
|
| 133 |
// ----- |
| 134 |
|
| 135 |
!s32i = !cir.int<s, 32> |
| 136 |
!s64i = !cir.int<s, 64> |
| 137 |
|
| 138 |
module { |
| 139 |
cir.func @vector_shuffle_invalid_index_value() -> !cir.vector<4 x !s32i> { |
| 140 |
%vec_1 = cir.const #cir.const_vector<[#cir.int<1> : !s32i, #cir.int<3> : !s32i, #cir.int<5> : !s32i, #cir.int<7> : !s32i]> : !cir.vector<4 x !s32i> |
| 141 |
%vec_2 = cir.const #cir.const_vector<[#cir.int<2> : !s32i, #cir.int<4> : !s32i, #cir.int<6> : !s32i, #cir.int<8> : !s32i]> : !cir.vector<4 x !s32i> |
| 142 |
|
| 143 |
// expected-error @below {{index for __builtin_shufflevector must be less than the total number of vector elements}} |
| 144 |
%new_vec = cir.vec.shuffle(%vec_1, %vec_2 : !cir.vector<4 x !s32i>) [#cir.int<9> : !s64i, #cir.int<4> : !s64i, |
| 145 |
#cir.int<1> : !s64i, #cir.int<5> : !s64i] : !cir.vector<4 x !s32i> |
| 146 |
cir.return %new_vec : !cir.vector<4 x !s32i> |
| 147 |
} |
| 148 |
} |
| 149 |
|
| 150 |
// ----- |
| 151 |
|
| 152 |
!s32i = !cir.int<s, 32> |
| 153 |
|
| 154 |
module { |
| 155 |
|
| 156 |
// expected-error @below {{the number of vector elements must be non-zero}} |
| 157 |
cir.global external @vec_a = #cir.zero : !cir.vector<0 x !s32i> |
| 158 |
|
| 159 |
} |