@@ -15,7 +15,7 @@ cir.global external @vec_b = #cir.zero : !cir.vector<4 x !cir.array<!s32i x 10>>
15
15
!s64i = !cir.int<s, 64>
16
16
17
17
module {
18
- cir.func @invalid_vector_shuffle () {
18
+ cir.func @vector_shuffle_invalid_element_type () {
19
19
%1 = cir.const #cir.int<1> : !s32i
20
20
%2 = cir.const #cir.int<2> : !s32i
21
21
%3 = cir.const #cir.int<3> : !s32i
@@ -34,7 +34,7 @@ module {
34
34
!s64i = !cir.int<s, 64>
35
35
36
36
module {
37
- cir.func @invalid_vector_shuffle () {
37
+ cir.func @vector_shuffle_different_number_of_elements () {
38
38
%1 = cir.const #cir.int<1> : !s32i
39
39
%2 = cir.const #cir.int<2> : !s32i
40
40
%3 = cir.const #cir.int<3> : !s32i
@@ -46,3 +46,104 @@ module {
46
46
cir.return
47
47
}
48
48
}
49
+
50
+ // -----
51
+
52
+ !s32i = !cir.int<s, 32>
53
+
54
+ module {
55
+ cir.func @vector_create_different_size() {
56
+ %1 = cir.const #cir.int<1> : !s32i
57
+ %2 = cir.const #cir.int<2> : !s32i
58
+ %3 = cir.const #cir.int<3> : !s32i
59
+ %4 = cir.const #cir.int<4> : !s32i
60
+
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.return
64
+ }
65
+ }
66
+
67
+ // -----
68
+
69
+ !s32i = !cir.int<s, 32>
70
+ !s64i = !cir.int<s, 64>
71
+
72
+ module {
73
+ cir.func @vector_create_different_type_size() {
74
+ %1 = cir.const #cir.int<1> : !s32i
75
+ %2 = cir.const #cir.int<2> : !s32i
76
+ %3 = cir.const #cir.int<3> : !s32i
77
+ %4 = cir.const #cir.int<4> : !s64i
78
+
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.return
82
+ }
83
+ }
84
+
85
+ // -----
86
+
87
+ !s32i = !cir.int<s, 32>
88
+
89
+ module {
90
+ cir.func @vector_shift_invalid_result_type() {
91
+ %1 = cir.const #cir.int<1> : !s32i
92
+ %2 = cir.const #cir.int<2> : !s32i
93
+ %3 = cir.const #cir.int<3> : !s32i
94
+ %4 = cir.const #cir.int<4> : !s32i
95
+ %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>) -> !s32i
99
+ cir.return
100
+ }
101
+ }
102
+
103
+ // -----
104
+
105
+ !s32i = !cir.int<s, 32>
106
+ !s64i = !cir.int<s, 64>
107
+
108
+ module {
109
+ cir.func @vector_shuffle_dynamic_different_number_of_elements() {
110
+ %1 = cir.const #cir.int<1> : !s32i
111
+ %2 = cir.const #cir.int<2> : !s32i
112
+ %3 = cir.const #cir.int<3> : !s32i
113
+ %4 = cir.const #cir.int<4> : !s32i
114
+ %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.return
120
+ }
121
+ }
122
+
123
+ // -----
124
+
125
+ !s32i = !cir.int<s, 32>
126
+ !s64i = !cir.int<s, 64>
127
+
128
+ module {
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
+
144
+ module {
145
+
146
+ // expected-error @below {{the number of vector elements must be non-zero}}
147
+ cir.global external @vec_a = #cir.zero : !cir.vector<0 x !s32i>
148
+
149
+ }
0 commit comments