[clang] [CIR][NFS] Merge vector type invalid tests and update names (PR #145238)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Jun 22 07:44:00 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clangir
@llvm/pr-subscribers-clang
Author: Amr Hesham (AmrDeveloper)
<details>
<summary>Changes</summary>
- Merge all vector-type invalid tests into one file.
- Update the names of the functions in the invalid test
Issue https://github.com/llvm/llvm-project/issues/136487
---
Full diff: https://github.com/llvm/llvm-project/pull/145238.diff
8 Files Affected:
- (removed) clang/test/CIR/IR/invalid-vector-create-wrong-size.cir (-16)
- (removed) clang/test/CIR/IR/invalid-vector-create-wrong-type.cir (-17)
- (removed) clang/test/CIR/IR/invalid-vector-shift-wrong-result-type.cir (-17)
- (removed) clang/test/CIR/IR/invalid-vector-shuffle-dyn-wrong-operands.cir (-19)
- (removed) clang/test/CIR/IR/invalid-vector-shuffle-wrong-index.cir (-16)
- (removed) clang/test/CIR/IR/invalid-vector-zero-size.cir (-10)
- (modified) clang/test/CIR/IR/invalid-vector.cir (+103-2)
- (modified) clang/test/CIR/Transforms/vector-splat.cir (+2-2)
``````````diff
diff --git a/clang/test/CIR/IR/invalid-vector-create-wrong-size.cir b/clang/test/CIR/IR/invalid-vector-create-wrong-size.cir
deleted file mode 100644
index 38ae74e83fb9e..0000000000000
--- a/clang/test/CIR/IR/invalid-vector-create-wrong-size.cir
+++ /dev/null
@@ -1,16 +0,0 @@
-// RUN: cir-opt %s -verify-diagnostics -split-input-file
-
-!s32i = !cir.int<s, 32>
-
-module {
- cir.func @foo() {
- %1 = cir.const #cir.int<1> : !s32i
- %2 = cir.const #cir.int<2> : !s32i
- %3 = cir.const #cir.int<3> : !s32i
- %4 = cir.const #cir.int<4> : !s32i
-
- // expected-error @below {{operand count of 4 doesn't match vector type '!cir.vector<8 x !cir.int<s, 32>>' element count of 8}}
- %5 = cir.vec.create(%1, %2, %3, %4 : !s32i, !s32i, !s32i, !s32i) : !cir.vector<8 x !s32i>
- cir.return
- }
-}
diff --git a/clang/test/CIR/IR/invalid-vector-create-wrong-type.cir b/clang/test/CIR/IR/invalid-vector-create-wrong-type.cir
deleted file mode 100644
index ded0e6072b536..0000000000000
--- a/clang/test/CIR/IR/invalid-vector-create-wrong-type.cir
+++ /dev/null
@@ -1,17 +0,0 @@
-// RUN: cir-opt %s -verify-diagnostics -split-input-file
-
-!s32i = !cir.int<s, 32>
-!s64i = !cir.int<s, 64>
-
-module {
- cir.func @foo() {
- %1 = cir.const #cir.int<1> : !s32i
- %2 = cir.const #cir.int<2> : !s32i
- %3 = cir.const #cir.int<3> : !s32i
- %4 = cir.const #cir.int<4> : !s64i
-
- // expected-error @below {{operand type '!cir.int<s, 64>' doesn't match vector element type '!cir.int<s, 32>'}}
- %5 = cir.vec.create(%1, %2, %3, %4 : !s32i, !s32i, !s32i, !s64i) : !cir.vector<4 x !s32i>
- cir.return
- }
-}
diff --git a/clang/test/CIR/IR/invalid-vector-shift-wrong-result-type.cir b/clang/test/CIR/IR/invalid-vector-shift-wrong-result-type.cir
deleted file mode 100644
index 5de9df9d572b2..0000000000000
--- a/clang/test/CIR/IR/invalid-vector-shift-wrong-result-type.cir
+++ /dev/null
@@ -1,17 +0,0 @@
-// RUN: cir-opt %s -verify-diagnostics -split-input-file
-
-!s32i = !cir.int<s, 32>
-
-module {
- cir.func @foo() {
- %1 = cir.const #cir.int<1> : !s32i
- %2 = cir.const #cir.int<2> : !s32i
- %3 = cir.const #cir.int<3> : !s32i
- %4 = cir.const #cir.int<4> : !s32i
- %5 = cir.vec.create(%1, %2, %3, %4 : !s32i, !s32i, !s32i, !s32i) : !cir.vector<4 x !s32i>
- %6 = cir.vec.create(%1, %2, %3, %4 : !s32i, !s32i, !s32i, !s32i) : !cir.vector<4 x !s32i>
- // expected-error @below {{the type of the result must be a vector if it is vector shift}}
- %7 = cir.shift(left, %5 : !cir.vector<4 x !s32i>, %6 : !cir.vector<4 x !s32i>) -> !s32i
- cir.return
- }
-}
diff --git a/clang/test/CIR/IR/invalid-vector-shuffle-dyn-wrong-operands.cir b/clang/test/CIR/IR/invalid-vector-shuffle-dyn-wrong-operands.cir
deleted file mode 100644
index 2115e769e1773..0000000000000
--- a/clang/test/CIR/IR/invalid-vector-shuffle-dyn-wrong-operands.cir
+++ /dev/null
@@ -1,19 +0,0 @@
-// RUN: cir-opt %s -verify-diagnostics -split-input-file
-
-!s32i = !cir.int<s, 32>
-!s64i = !cir.int<s, 64>
-
-module {
- cir.func @foo() {
- %1 = cir.const #cir.int<1> : !s32i
- %2 = cir.const #cir.int<2> : !s32i
- %3 = cir.const #cir.int<3> : !s32i
- %4 = cir.const #cir.int<4> : !s32i
- %vec = cir.vec.create(%1, %2, %3, %4 : !s32i, !s32i, !s32i, !s32i) : !cir.vector<4 x !s32i>
- %indices = cir.vec.create(%1, %2 : !s32i, !s32i) : !cir.vector<2 x !s32i>
-
- // 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}}
- %new_vec = cir.vec.shuffle.dynamic %vec : !cir.vector<4 x !s32i>, %indices : !cir.vector<2 x !s32i>
- cir.return
- }
-}
diff --git a/clang/test/CIR/IR/invalid-vector-shuffle-wrong-index.cir b/clang/test/CIR/IR/invalid-vector-shuffle-wrong-index.cir
deleted file mode 100644
index 375b2d3dc563e..0000000000000
--- a/clang/test/CIR/IR/invalid-vector-shuffle-wrong-index.cir
+++ /dev/null
@@ -1,16 +0,0 @@
-// RUN: cir-opt %s -verify-diagnostics -split-input-file
-
-!s32i = !cir.int<s, 32>
-!s64i = !cir.int<s, 64>
-
-module {
- cir.func @fold_shuffle_vector_op_test() -> !cir.vector<4 x !s32i> {
- %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>
- %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>
-
- // expected-error @below {{index for __builtin_shufflevector must be less than the total number of vector elements}}
- %new_vec = cir.vec.shuffle(%vec_1, %vec_2 : !cir.vector<4 x !s32i>) [#cir.int<9> : !s64i, #cir.int<4> : !s64i,
- #cir.int<1> : !s64i, #cir.int<5> : !s64i] : !cir.vector<4 x !s32i>
- cir.return %new_vec : !cir.vector<4 x !s32i>
- }
-}
diff --git a/clang/test/CIR/IR/invalid-vector-zero-size.cir b/clang/test/CIR/IR/invalid-vector-zero-size.cir
deleted file mode 100644
index ffe6c56a28aa1..0000000000000
--- a/clang/test/CIR/IR/invalid-vector-zero-size.cir
+++ /dev/null
@@ -1,10 +0,0 @@
-// RUN: cir-opt %s -verify-diagnostics -split-input-file
-
-!s32i = !cir.int<s, 32>
-
-module {
-
-// expected-error @below {{the number of vector elements must be non-zero}}
-cir.global external @vec_a = #cir.zero : !cir.vector<0 x !s32i>
-
-}
diff --git a/clang/test/CIR/IR/invalid-vector.cir b/clang/test/CIR/IR/invalid-vector.cir
index 98e1109df84f9..679994925786e 100644
--- a/clang/test/CIR/IR/invalid-vector.cir
+++ b/clang/test/CIR/IR/invalid-vector.cir
@@ -15,7 +15,7 @@ cir.global external @vec_b = #cir.zero : !cir.vector<4 x !cir.array<!s32i x 10>>
!s64i = !cir.int<s, 64>
module {
- cir.func @invalid_vector_shuffle() {
+ cir.func @vector_shuffle_invalid_element_type() {
%1 = cir.const #cir.int<1> : !s32i
%2 = cir.const #cir.int<2> : !s32i
%3 = cir.const #cir.int<3> : !s32i
@@ -34,7 +34,7 @@ module {
!s64i = !cir.int<s, 64>
module {
- cir.func @invalid_vector_shuffle() {
+ cir.func @vector_shuffle_different_number_of_elements() {
%1 = cir.const #cir.int<1> : !s32i
%2 = cir.const #cir.int<2> : !s32i
%3 = cir.const #cir.int<3> : !s32i
@@ -46,3 +46,104 @@ module {
cir.return
}
}
+
+// -----
+
+!s32i = !cir.int<s, 32>
+
+module {
+ cir.func @vector_create_different_size() {
+ %1 = cir.const #cir.int<1> : !s32i
+ %2 = cir.const #cir.int<2> : !s32i
+ %3 = cir.const #cir.int<3> : !s32i
+ %4 = cir.const #cir.int<4> : !s32i
+
+ // expected-error @below {{operand count of 4 doesn't match vector type '!cir.vector<8 x !cir.int<s, 32>>' element count of 8}}
+ %5 = cir.vec.create(%1, %2, %3, %4 : !s32i, !s32i, !s32i, !s32i) : !cir.vector<8 x !s32i>
+ cir.return
+ }
+}
+
+// -----
+
+!s32i = !cir.int<s, 32>
+!s64i = !cir.int<s, 64>
+
+module {
+ cir.func @vector_create_different_type_size() {
+ %1 = cir.const #cir.int<1> : !s32i
+ %2 = cir.const #cir.int<2> : !s32i
+ %3 = cir.const #cir.int<3> : !s32i
+ %4 = cir.const #cir.int<4> : !s64i
+
+ // expected-error @below {{operand type '!cir.int<s, 64>' doesn't match vector element type '!cir.int<s, 32>'}}
+ %5 = cir.vec.create(%1, %2, %3, %4 : !s32i, !s32i, !s32i, !s64i) : !cir.vector<4 x !s32i>
+ cir.return
+ }
+}
+
+// -----
+
+!s32i = !cir.int<s, 32>
+
+module {
+ cir.func @vector_shift_invalid_result_type() {
+ %1 = cir.const #cir.int<1> : !s32i
+ %2 = cir.const #cir.int<2> : !s32i
+ %3 = cir.const #cir.int<3> : !s32i
+ %4 = cir.const #cir.int<4> : !s32i
+ %5 = cir.vec.create(%1, %2, %3, %4 : !s32i, !s32i, !s32i, !s32i) : !cir.vector<4 x !s32i>
+ %6 = cir.vec.create(%1, %2, %3, %4 : !s32i, !s32i, !s32i, !s32i) : !cir.vector<4 x !s32i>
+ // expected-error @below {{the type of the result must be a vector if it is vector shift}}
+ %7 = cir.shift(left, %5 : !cir.vector<4 x !s32i>, %6 : !cir.vector<4 x !s32i>) -> !s32i
+ cir.return
+ }
+}
+
+// -----
+
+!s32i = !cir.int<s, 32>
+!s64i = !cir.int<s, 64>
+
+module {
+ cir.func @vector_shuffle_dynamic_different_number_of_elements() {
+ %1 = cir.const #cir.int<1> : !s32i
+ %2 = cir.const #cir.int<2> : !s32i
+ %3 = cir.const #cir.int<3> : !s32i
+ %4 = cir.const #cir.int<4> : !s32i
+ %vec = cir.vec.create(%1, %2, %3, %4 : !s32i, !s32i, !s32i, !s32i) : !cir.vector<4 x !s32i>
+ %indices = cir.vec.create(%1, %2 : !s32i, !s32i) : !cir.vector<2 x !s32i>
+
+ // 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}}
+ %new_vec = cir.vec.shuffle.dynamic %vec : !cir.vector<4 x !s32i>, %indices : !cir.vector<2 x !s32i>
+ cir.return
+ }
+}
+
+// -----
+
+!s32i = !cir.int<s, 32>
+!s64i = !cir.int<s, 64>
+
+module {
+ cir.func @vector_shuffle_invalid_index_value() -> !cir.vector<4 x !s32i> {
+ %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>
+ %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>
+
+ // expected-error @below {{index for __builtin_shufflevector must be less than the total number of vector elements}}
+ %new_vec = cir.vec.shuffle(%vec_1, %vec_2 : !cir.vector<4 x !s32i>) [#cir.int<9> : !s64i, #cir.int<4> : !s64i,
+ #cir.int<1> : !s64i, #cir.int<5> : !s64i] : !cir.vector<4 x !s32i>
+ cir.return %new_vec : !cir.vector<4 x !s32i>
+ }
+}
+
+// -----
+
+!s32i = !cir.int<s, 32>
+
+module {
+
+// expected-error @below {{the number of vector elements must be non-zero}}
+cir.global external @vec_a = #cir.zero : !cir.vector<0 x !s32i>
+
+}
diff --git a/clang/test/CIR/Transforms/vector-splat.cir b/clang/test/CIR/Transforms/vector-splat.cir
index e2274b8627b17..9b2b39d7f862e 100644
--- a/clang/test/CIR/Transforms/vector-splat.cir
+++ b/clang/test/CIR/Transforms/vector-splat.cir
@@ -3,13 +3,13 @@
!s32i = !cir.int<s, 32>
module {
- cir.func @fold_shuffle_vector_op_test() -> !cir.vector<4 x !s32i> {
+ cir.func @fold_splat_vector_op_test() -> !cir.vector<4 x !s32i> {
%v = cir.const #cir.int<3> : !s32i
%vec = cir.vec.splat %v : !s32i, !cir.vector<4 x !s32i>
cir.return %vec : !cir.vector<4 x !s32i>
}
- // CHECK: cir.func @fold_shuffle_vector_op_test() -> !cir.vector<4 x !s32i> {
+ // CHECK: cir.func @fold_splat_vector_op_test() -> !cir.vector<4 x !s32i> {
// CHECK-NEXT: %0 = cir.const #cir.const_vector<[#cir.int<3> : !s32i, #cir.int<3> : !s32i,
// CHECK-SAME: #cir.int<3> : !s32i, #cir.int<3> : !s32i]> : !cir.vector<4 x !s32i>
// CHECK-NEXT: cir.return %0 : !cir.vector<4 x !s32i>
``````````
</details>
https://github.com/llvm/llvm-project/pull/145238
More information about the cfe-commits
mailing list