Skip to content

Commit 4c3de45

Browse files
authored
[LoongArch][test] Add tests reporting error if lsx/lasx feature is missing when lsx/lasx builtins are called (#79250)
1 parent 502ec2e commit 4c3de45

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

clang/test/CodeGen/LoongArch/lasx/builtin-error.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// RUN: %clang_cc1 -triple loongarch64 -target-feature +lasx -verify %s
2+
// RUN: not %clang_cc1 -triple loongarch64 -DFEATURE_CHECK -emit-llvm %s -o /dev/null 2>&1 \
3+
// RUN: | FileCheck %s
24

35
typedef signed char v32i8 __attribute__((vector_size(32), aligned(32)));
46
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)));
2123
typedef double v4f64 __attribute__((vector_size(32), aligned(32)));
2224
typedef double v4f64_d __attribute__((vector_size(32), aligned(8)));
2325

26+
#ifdef FEATURE_CHECK
27+
void test_feature(v32i8 _1) {
28+
// CHECK: error: '__builtin_lasx_xvslli_b' needs target feature lasx
29+
(void)__builtin_lasx_xvslli_b(_1, 1);
30+
}
31+
#endif
32+
2433
v32i8 xvslli_b(v32i8 _1, int var) {
2534
v32i8 res = __builtin_lasx_xvslli_b(_1, -1); // expected-error {{argument value 4294967295 is outside the valid range [0, 7]}}
2635
res |= __builtin_lasx_xvslli_b(_1, 8); // expected-error {{argument value 8 is outside the valid range [0, 7]}}

clang/test/CodeGen/LoongArch/lsx/builtin-error.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// RUN: %clang_cc1 -triple loongarch64 -target-feature +lsx -verify %s
2+
// RUN: not %clang_cc1 -triple loongarch64 -DFEATURE_CHECK -emit-llvm %s -o /dev/null 2>&1 \
3+
// RUN: | FileCheck %s
24

35
typedef signed char v16i8 __attribute__((vector_size(16), aligned(16)));
46
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__));
2527
typedef float __m128 __attribute__((__vector_size__(16), __may_alias__));
2628
typedef double __m128d __attribute__((__vector_size__(16), __may_alias__));
2729

30+
#ifdef FEATURE_CHECK
31+
void test_feature(v16i8 _1) {
32+
// CHECK: error: '__builtin_lsx_vslli_b' needs target feature lsx
33+
(void)__builtin_lsx_vslli_b(_1, 1);
34+
}
35+
#endif
36+
2837
v16i8 vslli_b(v16i8 _1, int var) {
2938
v16i8 res = __builtin_lsx_vslli_b(_1, -1); // expected-error {{argument value 4294967295 is outside the valid range [0, 7]}}
3039
res |= __builtin_lsx_vslli_b(_1, 8); // expected-error {{argument value 8 is outside the valid range [0, 7]}}

0 commit comments

Comments
 (0)