Skip to content

Commit

Permalink
[LoongArch][test] Add tests reporting error if lsx/lasx feature is mi…
Browse files Browse the repository at this point in the history
…ssing when lsx/lasx builtins are called (#79250)
  • Loading branch information
leecheechen committed Jan 24, 2024
1 parent 502ec2e commit 4c3de45
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions clang/test/CodeGen/LoongArch/lasx/builtin-error.c
Original file line number Diff line number Diff line change
@@ -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)));
Expand All @@ -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]}}
Expand Down
9 changes: 9 additions & 0 deletions clang/test/CodeGen/LoongArch/lsx/builtin-error.c
Original file line number Diff line number Diff line change
@@ -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)));
Expand All @@ -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]}}
Expand Down

0 comments on commit 4c3de45

Please sign in to comment.