Skip to content

Commit fbbae9e

Browse files
committed
[LoongArch] Only report the first range error if there is actually more than one for __builtin_loongarch_cacop_[wd]
Other builtins do the same. Align with them.
1 parent c9022a2 commit fbbae9e

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

clang/lib/Sema/SemaLoongArch.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,9 @@ bool SemaLoongArch::CheckLoongArchBuiltinFunctionCall(const TargetInfo &TI,
2828
// Basic intrinsics.
2929
case LoongArch::BI__builtin_loongarch_cacop_d:
3030
case LoongArch::BI__builtin_loongarch_cacop_w: {
31-
SemaRef.BuiltinConstantArgRange(TheCall, 0, 0, llvm::maxUIntN(5));
32-
SemaRef.BuiltinConstantArgRange(TheCall, 2, llvm::minIntN(12),
33-
llvm::maxIntN(12));
34-
break;
31+
return SemaRef.BuiltinConstantArgRange(TheCall, 0, 0, llvm::maxUIntN(5)) ||
32+
SemaRef.BuiltinConstantArgRange(TheCall, 2, llvm::minIntN(12),
33+
llvm::maxIntN(12));
3534
}
3635
case LoongArch::BI__builtin_loongarch_break:
3736
case LoongArch::BI__builtin_loongarch_dbar:

clang/test/CodeGen/LoongArch/intrinsic-la32-error.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,12 @@ void test_feature(long *v_l, unsigned long *v_ul, int *v_i, unsigned ui, char c,
5252
}
5353
#endif
5454

55-
void cacop_d(unsigned long int a) {
55+
void cacop_w(unsigned long int a) {
5656
__builtin_loongarch_cacop_w(-1, a, 1024); // expected-error {{argument value -1 is outside the valid range [0, 31]}}
5757
__builtin_loongarch_cacop_w(32, a, 1024); // expected-error {{argument value 32 is outside the valid range [0, 31]}}
5858
__builtin_loongarch_cacop_w(1, a, -4096); // expected-error {{argument value -4096 is outside the valid range [-2048, 2047]}}
5959
__builtin_loongarch_cacop_w(1, a, 4096); // expected-error {{argument value 4096 is outside the valid range [-2048, 2047]}}
60+
__builtin_loongarch_cacop_w(-2, a, 5000); // expected-error {{argument value -2 is outside the valid range [0, 31]}}
6061
}
6162

6263
void dbar(int a) {

clang/test/CodeGen/LoongArch/intrinsic-la64-error.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ void test_feature(unsigned long *v_ul, int *v_i, float a, double b) {
2323
}
2424
#endif
2525

26+
void cacop_d(int a) {
27+
__builtin_loongarch_cacop_d(-1, a, 0); // expected-error {{argument value -1 is outside the valid range [0, 31]}}
28+
__builtin_loongarch_cacop_d(1, a, 4000); // expected-error {{argument value 4000 is outside the valid range [-2048, 2047]}}
29+
__builtin_loongarch_cacop_d(-2, a, 5000); // expected-error {{argument value -2 is outside the valid range [0, 31]}}
30+
}
31+
2632
void csrrd_d(int a) {
2733
__builtin_loongarch_csrrd_d(16384); // expected-error {{argument value 16384 is outside the valid range [0, 16383]}}
2834
__builtin_loongarch_csrrd_d(-1); // expected-error {{argument value 4294967295 is outside the valid range [0, 16383]}}

0 commit comments

Comments
 (0)