-
Notifications
You must be signed in to change notification settings - Fork 12.4k
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
[Clang][LoongArch] Fix wrong return value type of __iocsrrd_h #84100
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
llvmbot
added
clang
Clang issues not falling into any other category
backend:X86
clang:headers
Headers provided by Clang, e.g. for intrinsics
labels
Mar 6, 2024
@llvm/pr-subscribers-backend-loongarch @llvm/pr-subscribers-clang Author: wanglei (wangleiat) Changesrelate: Full diff: https://github.com/llvm/llvm-project/pull/84100.diff 3 Files Affected:
diff --git a/clang/lib/Headers/larchintrin.h b/clang/lib/Headers/larchintrin.h
index a613e5ca0e5ecd..f4218295919a0d 100644
--- a/clang/lib/Headers/larchintrin.h
+++ b/clang/lib/Headers/larchintrin.h
@@ -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);
diff --git a/clang/test/CodeGen/LoongArch/intrinsic-la32.c b/clang/test/CodeGen/LoongArch/intrinsic-la32.c
index 6a8d99880be399..eb3f8cbe7ac4cc 100644
--- a/clang/test/CodeGen/LoongArch/intrinsic-la32.c
+++ b/clang/test/CodeGen/LoongArch/intrinsic-la32.c
@@ -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);
diff --git a/clang/test/CodeGen/LoongArch/intrinsic-la64.c b/clang/test/CodeGen/LoongArch/intrinsic-la64.c
index 48b6a7a3d22704..50ec358f546ec0 100644
--- a/clang/test/CodeGen/LoongArch/intrinsic-la64.c
+++ b/clang/test/CodeGen/LoongArch/intrinsic-la64.c
@@ -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);
|
SixWeining
approved these changes
Mar 6, 2024
llvmbot
pushed a commit
to llvmbot/llvm-project
that referenced
this pull request
Mar 11, 2024
…4100) relate: https://gcc.gnu.org/pipermail/gcc-patches/2024-February/645016.html (cherry picked from commit 2f479b8)
llvmbot
pushed a commit
to llvmbot/llvm-project
that referenced
this pull request
Mar 13, 2024
…4100) relate: https://gcc.gnu.org/pipermail/gcc-patches/2024-February/645016.html (cherry picked from commit 2f479b8)
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
backend:loongarch
clang:headers
Headers provided by Clang, e.g. for intrinsics
clang
Clang issues not falling into any other category
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
relate:
https://gcc.gnu.org/pipermail/gcc-patches/2024-February/645016.html