150 lines · plain
1// RUN: cir-opt %s -verify-diagnostics -split-input-file2 3!s32i = !cir.int<s, 32>4 5module {6 7// expected-error @below {{failed to verify 'elementType'}}8cir.global external @vec_b = #cir.zero : !cir.vector<4 x !cir.array<!s32i x 10>>9 10}11 12// -----13 14!s32i = !cir.int<s, 32>15!s64i = !cir.int<s, 64>16 17module {18 cir.func @vector_shuffle_invalid_element_type() {19 %1 = cir.const #cir.int<1> : !s32i20 %2 = cir.const #cir.int<2> : !s32i21 %3 = cir.const #cir.int<3> : !s32i22 %4 = cir.const #cir.int<4> : !s32i23 %vec_1 = cir.vec.create(%1, %2, %3, %4 : !s32i, !s32i, !s32i, !s32i) : !cir.vector<4 x !s32i>24 %vec_2 = cir.vec.create(%1, %2, %3, %4 : !s32i, !s32i, !s32i, !s32i) : !cir.vector<4 x !s32i>25 // 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}}26 %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>27 cir.return28 }29}30 31// -----32 33!s32i = !cir.int<s, 32>34!s64i = !cir.int<s, 64>35 36module {37 cir.func @vector_shuffle_different_number_of_elements() {38 %1 = cir.const #cir.int<1> : !s32i39 %2 = cir.const #cir.int<2> : !s32i40 %3 = cir.const #cir.int<3> : !s32i41 %4 = cir.const #cir.int<4> : !s32i42 %vec_1 = cir.vec.create(%1, %2, %3, %4 : !s32i, !s32i, !s32i, !s32i) : !cir.vector<4 x !s32i>43 %vec_2 = cir.vec.create(%1, %2, %3, %4 : !s32i, !s32i, !s32i, !s32i) : !cir.vector<4 x !s32i>44 // 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}}45 %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>46 cir.return47 }48}49 50// -----51 52!s32i = !cir.int<s, 32>53 54module {55 cir.func @vector_create_different_size() {56 %1 = cir.const #cir.int<1> : !s32i57 %2 = cir.const #cir.int<2> : !s32i58 %3 = cir.const #cir.int<3> : !s32i59 %4 = cir.const #cir.int<4> : !s32i60 61 // expected-error @below {{operand count of 4 doesn't match vector type '!cir.vector<8 x !cir.int<s, 32>>' element count of 8}}62 %5 = cir.vec.create(%1, %2, %3, %4 : !s32i, !s32i, !s32i, !s32i) : !cir.vector<8 x !s32i>63 cir.return64 }65}66 67// -----68 69!s32i = !cir.int<s, 32>70!s64i = !cir.int<s, 64>71 72module {73 cir.func @vector_create_different_type_size() {74 %1 = cir.const #cir.int<1> : !s32i75 %2 = cir.const #cir.int<2> : !s32i76 %3 = cir.const #cir.int<3> : !s32i77 %4 = cir.const #cir.int<4> : !s64i78 79 // expected-error @below {{operand type '!cir.int<s, 64>' doesn't match vector element type '!cir.int<s, 32>'}}80 %5 = cir.vec.create(%1, %2, %3, %4 : !s32i, !s32i, !s32i, !s64i) : !cir.vector<4 x !s32i>81 cir.return82 }83}84 85// -----86 87!s32i = !cir.int<s, 32>88 89module {90 cir.func @vector_shift_invalid_result_type() {91 %1 = cir.const #cir.int<1> : !s32i92 %2 = cir.const #cir.int<2> : !s32i93 %3 = cir.const #cir.int<3> : !s32i94 %4 = cir.const #cir.int<4> : !s32i95 %5 = cir.vec.create(%1, %2, %3, %4 : !s32i, !s32i, !s32i, !s32i) : !cir.vector<4 x !s32i>96 %6 = cir.vec.create(%1, %2, %3, %4 : !s32i, !s32i, !s32i, !s32i) : !cir.vector<4 x !s32i>97 // expected-error @below {{the type of the result must be a vector if it is vector shift}}98 %7 = cir.shift(left, %5 : !cir.vector<4 x !s32i>, %6 : !cir.vector<4 x !s32i>) -> !s32i99 cir.return100 }101}102 103// -----104 105!s32i = !cir.int<s, 32>106!s64i = !cir.int<s, 64>107 108module {109 cir.func @vector_shuffle_dynamic_different_number_of_elements() {110 %1 = cir.const #cir.int<1> : !s32i111 %2 = cir.const #cir.int<2> : !s32i112 %3 = cir.const #cir.int<3> : !s32i113 %4 = cir.const #cir.int<4> : !s32i114 %vec = cir.vec.create(%1, %2, %3, %4 : !s32i, !s32i, !s32i, !s32i) : !cir.vector<4 x !s32i>115 %indices = cir.vec.create(%1, %2 : !s32i, !s32i) : !cir.vector<2 x !s32i>116 117 // 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}}118 %new_vec = cir.vec.shuffle.dynamic %vec : !cir.vector<4 x !s32i>, %indices : !cir.vector<2 x !s32i>119 cir.return120 }121}122 123// -----124 125!s32i = !cir.int<s, 32>126!s64i = !cir.int<s, 64>127 128module {129 cir.func @vector_shuffle_invalid_index_value() -> !cir.vector<4 x !s32i> {130 %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>131 %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>132 133 // expected-error @below {{index for __builtin_shufflevector must be less than the total number of vector elements}}134 %new_vec = cir.vec.shuffle(%vec_1, %vec_2 : !cir.vector<4 x !s32i>) [#cir.int<9> : !s64i, #cir.int<4> : !s64i,135 #cir.int<1> : !s64i, #cir.int<5> : !s64i] : !cir.vector<4 x !s32i>136 cir.return %new_vec : !cir.vector<4 x !s32i>137 }138}139 140// -----141 142!s32i = !cir.int<s, 32>143 144module {145 146// expected-error @below {{the number of vector elements must be non-zero}}147cir.global external @vec_a = #cir.zero : !cir.vector<0 x !s32i>148 149}150