Skip to content

Commit

Permalink
[Clang][LoongArch] Fix wrong return value type of __iocsrrd_h (llvm#8…
Browse files Browse the repository at this point in the history
  • Loading branch information
wangleiat authored and llvmbot committed Mar 11, 2024
1 parent a31f312 commit 2e64d18
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion clang/lib/Headers/larchintrin.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ extern __inline unsigned char
return (unsigned char)__builtin_loongarch_iocsrrd_b((unsigned int)_1);
}

extern __inline unsigned char
extern __inline unsigned short
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
__iocsrrd_h(unsigned int _1) {
return (unsigned short)__builtin_loongarch_iocsrrd_h((unsigned int)_1);
Expand Down
8 changes: 4 additions & 4 deletions clang/test/CodeGen/LoongArch/intrinsic-la32.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,11 @@ void cacop_w(unsigned long int a) {
// LA32-LABEL: @iocsrrd_h_result(
// LA32-NEXT: entry:
// LA32-NEXT: [[TMP0:%.*]] = tail call i32 @llvm.loongarch.iocsrrd.h(i32 [[A:%.*]])
// LA32-NEXT: [[CONV_I:%.*]] = trunc i32 [[TMP0]] to i16
// LA32-NEXT: [[TMP1:%.*]] = tail call i32 @llvm.loongarch.iocsrrd.h(i32 [[A]])
// LA32-NEXT: [[CONV2:%.*]] = and i32 [[TMP0]], 255
// LA32-NEXT: [[ADD:%.*]] = add i32 [[TMP1]], [[CONV2]]
// LA32-NEXT: [[CONV4:%.*]] = trunc i32 [[ADD]] to i16
// LA32-NEXT: ret i16 [[CONV4]]
// LA32-NEXT: [[TMP2:%.*]] = trunc i32 [[TMP1]] to i16
// LA32-NEXT: [[CONV3:%.*]] = add i16 [[TMP2]], [[CONV_I]]
// LA32-NEXT: ret i16 [[CONV3]]
//
unsigned short iocsrrd_h_result(unsigned int a) {
unsigned short b = __iocsrrd_h(a);
Expand Down
8 changes: 4 additions & 4 deletions clang/test/CodeGen/LoongArch/intrinsic-la64.c
Original file line number Diff line number Diff line change
Expand Up @@ -431,11 +431,11 @@ void loongarch_movgr2fcsr(int a) {
// CHECK-LABEL: @iocsrrd_h_result(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[TMP0:%.*]] = tail call i32 @llvm.loongarch.iocsrrd.h(i32 [[A:%.*]])
// CHECK-NEXT: [[CONV_I:%.*]] = trunc i32 [[TMP0]] to i16
// CHECK-NEXT: [[TMP1:%.*]] = tail call i32 @llvm.loongarch.iocsrrd.h(i32 [[A]])
// CHECK-NEXT: [[CONV2:%.*]] = and i32 [[TMP0]], 255
// CHECK-NEXT: [[ADD:%.*]] = add i32 [[TMP1]], [[CONV2]]
// CHECK-NEXT: [[CONV4:%.*]] = trunc i32 [[ADD]] to i16
// CHECK-NEXT: ret i16 [[CONV4]]
// CHECK-NEXT: [[TMP2:%.*]] = trunc i32 [[TMP1]] to i16
// CHECK-NEXT: [[CONV3:%.*]] = add i16 [[TMP2]], [[CONV_I]]
// CHECK-NEXT: ret i16 [[CONV3]]
//
unsigned short iocsrrd_h_result(unsigned int a) {
unsigned short b = __iocsrrd_h(a);
Expand Down

0 comments on commit 2e64d18

Please sign in to comment.