Skip to content

[LoongArch] Check lsx/lasx features when running builtin tests #79250

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 24, 2024

Conversation

leecheechen
Copy link
Contributor

This patch refers to the following test:
clang/test/CodeGen/LoongArch/intrinsic-la32-error.c

This patch refers to the following test:
clang/test/CodeGen/LoongArch/intrinsic-la32-error.c
@llvmbot llvmbot added the clang Clang issues not falling into any other category label Jan 24, 2024
@llvmbot
Copy link
Member

llvmbot commented Jan 24, 2024

@llvm/pr-subscribers-clang

Author: None (leecheechen)

Changes

This patch refers to the following test:
clang/test/CodeGen/LoongArch/intrinsic-la32-error.c


Full diff: https://github.com/llvm/llvm-project/pull/79250.diff

2 Files Affected:

  • (modified) clang/test/CodeGen/LoongArch/lasx/builtin-error.c (+9)
  • (modified) clang/test/CodeGen/LoongArch/lsx/builtin-error.c (+9)
diff --git a/clang/test/CodeGen/LoongArch/lasx/builtin-error.c b/clang/test/CodeGen/LoongArch/lasx/builtin-error.c
index 724484465769e0e..dabf34368ea3e13 100644
--- a/clang/test/CodeGen/LoongArch/lasx/builtin-error.c
+++ b/clang/test/CodeGen/LoongArch/lasx/builtin-error.c
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -triple loongarch64 -target-feature +lasx -verify %s
+// RUN: not %clang_cc1 -triple loongarch64 -DFEATURE_CHECK -emit-llvm %s -o /dev/null 2>&1 \
+// RUN:   | FileCheck %s
 
 typedef signed char v32i8 __attribute__((vector_size(32), aligned(32)));
 typedef signed char v32i8_b __attribute__((vector_size(32), aligned(1)));
@@ -21,6 +23,13 @@ typedef float v8f32_w __attribute__((vector_size(32), aligned(4)));
 typedef double v4f64 __attribute__((vector_size(32), aligned(32)));
 typedef double v4f64_d __attribute__((vector_size(32), aligned(8)));
 
+#ifdef FEATURE_CHECK
+void test_feature(v32i8 _1) {
+// CHECK: error: '__builtin_lasx_xvslli_b' needs target feature lasx
+  (void)__builtin_lasx_xvslli_b(_1, 1);
+}
+#endif
+
 v32i8 xvslli_b(v32i8 _1, int var) {
   v32i8 res = __builtin_lasx_xvslli_b(_1, -1); // expected-error {{argument value 4294967295 is outside the valid range [0, 7]}}
   res |= __builtin_lasx_xvslli_b(_1, 8); // expected-error {{argument value 8 is outside the valid range [0, 7]}}
diff --git a/clang/test/CodeGen/LoongArch/lsx/builtin-error.c b/clang/test/CodeGen/LoongArch/lsx/builtin-error.c
index 3fc5f73f11934e6..722ba7fe8cd20e4 100644
--- a/clang/test/CodeGen/LoongArch/lsx/builtin-error.c
+++ b/clang/test/CodeGen/LoongArch/lsx/builtin-error.c
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -triple loongarch64 -target-feature +lsx -verify %s
+// RUN: not %clang_cc1 -triple loongarch64 -DFEATURE_CHECK -emit-llvm %s -o /dev/null 2>&1 \
+// RUN:   | FileCheck %s
 
 typedef signed char v16i8 __attribute__((vector_size(16), aligned(16)));
 typedef signed char v16i8_b __attribute__((vector_size(16), aligned(1)));
@@ -25,6 +27,13 @@ typedef long long __m128i __attribute__((__vector_size__(16), __may_alias__));
 typedef float __m128 __attribute__((__vector_size__(16), __may_alias__));
 typedef double __m128d __attribute__((__vector_size__(16), __may_alias__));
 
+#ifdef FEATURE_CHECK
+void test_feature(v16i8 _1) {
+// CHECK: error: '__builtin_lsx_vslli_b' needs target feature lsx
+  (void)__builtin_lsx_vslli_b(_1, 1);
+}
+#endif
+
 v16i8 vslli_b(v16i8 _1, int var) {
   v16i8 res = __builtin_lsx_vslli_b(_1, -1); // expected-error {{argument value 4294967295 is outside the valid range [0, 7]}}
   res |= __builtin_lsx_vslli_b(_1, 8); // expected-error {{argument value 8 is outside the valid range [0, 7]}}

@leecheechen
Copy link
Contributor Author

cc @SixWeining

@SixWeining SixWeining self-requested a review January 24, 2024 05:08
@SixWeining SixWeining changed the title Check lsx/lasx features when running builtin tests [LoongArch][test] Add tests reporting error if lsx/lasx feature is missing when lsx/lasx builtins are called Jan 24, 2024
@SixWeining SixWeining merged commit 4c3de45 into llvm:main Jan 24, 2024
@leecheechen leecheechen changed the title [LoongArch][test] Add tests reporting error if lsx/lasx feature is missing when lsx/lasx builtins are called [LoongArch] Check lsx/lasx features when running builtin tests Jan 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants