Skip to content

Commit b3c5302

Browse files
authored
[CIR][NFC] Merge vector type invalid tests and update names (#145238)
- Merge all vector-type invalid tests into one file. - Update the names of the functions in the invalid test Issue #136487
1 parent 26d318e commit b3c5302

8 files changed

+105
-99
lines changed

clang/test/CIR/IR/invalid-vector-create-wrong-size.cir

Lines changed: 0 additions & 16 deletions
This file was deleted.

clang/test/CIR/IR/invalid-vector-create-wrong-type.cir

Lines changed: 0 additions & 17 deletions
This file was deleted.

clang/test/CIR/IR/invalid-vector-shift-wrong-result-type.cir

Lines changed: 0 additions & 17 deletions
This file was deleted.

clang/test/CIR/IR/invalid-vector-shuffle-dyn-wrong-operands.cir

Lines changed: 0 additions & 19 deletions
This file was deleted.

clang/test/CIR/IR/invalid-vector-shuffle-wrong-index.cir

Lines changed: 0 additions & 16 deletions
This file was deleted.

clang/test/CIR/IR/invalid-vector-zero-size.cir

Lines changed: 0 additions & 10 deletions
This file was deleted.

clang/test/CIR/IR/invalid-vector.cir

Lines changed: 103 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ cir.global external @vec_b = #cir.zero : !cir.vector<4 x !cir.array<!s32i x 10>>
1515
!s64i = !cir.int<s, 64>
1616

1717
module {
18-
cir.func @invalid_vector_shuffle() {
18+
cir.func @vector_shuffle_invalid_element_type() {
1919
%1 = cir.const #cir.int<1> : !s32i
2020
%2 = cir.const #cir.int<2> : !s32i
2121
%3 = cir.const #cir.int<3> : !s32i
@@ -34,7 +34,7 @@ module {
3434
!s64i = !cir.int<s, 64>
3535

3636
module {
37-
cir.func @invalid_vector_shuffle() {
37+
cir.func @vector_shuffle_different_number_of_elements() {
3838
%1 = cir.const #cir.int<1> : !s32i
3939
%2 = cir.const #cir.int<2> : !s32i
4040
%3 = cir.const #cir.int<3> : !s32i
@@ -46,3 +46,104 @@ module {
4646
cir.return
4747
}
4848
}
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+
}

clang/test/CIR/Transforms/vector-splat.cir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
!s32i = !cir.int<s, 32>
44

55
module {
6-
cir.func @fold_shuffle_vector_op_test() -> !cir.vector<4 x !s32i> {
6+
cir.func @fold_splat_vector_op_test() -> !cir.vector<4 x !s32i> {
77
%v = cir.const #cir.int<3> : !s32i
88
%vec = cir.vec.splat %v : !s32i, !cir.vector<4 x !s32i>
99
cir.return %vec : !cir.vector<4 x !s32i>
1010
}
1111

12-
// CHECK: cir.func @fold_shuffle_vector_op_test() -> !cir.vector<4 x !s32i> {
12+
// CHECK: cir.func @fold_splat_vector_op_test() -> !cir.vector<4 x !s32i> {
1313
// CHECK-NEXT: %0 = cir.const #cir.const_vector<[#cir.int<3> : !s32i, #cir.int<3> : !s32i,
1414
// CHECK-SAME: #cir.int<3> : !s32i, #cir.int<3> : !s32i]> : !cir.vector<4 x !s32i>
1515
// CHECK-NEXT: cir.return %0 : !cir.vector<4 x !s32i>

0 commit comments

Comments
 (0)