[PATCH] D153235: [RISCV] Change the type of argument to clz and ctz from ZiZi/WiWi to iUZi/iUWi
Jim Lin via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Jun 25 22:16:04 PDT 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG612b7e10a9af: [RISCV] Change the type of argument to clz and ctz from ZiZi/WiWi to iUZi/iUWi (authored by Jim).
Changed prior to commit:
https://reviews.llvm.org/D153235?vs=532790&id=534425#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D153235/new/
https://reviews.llvm.org/D153235
Files:
clang/include/clang/Basic/BuiltinsRISCV.def
clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
Index: clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
===================================================================
--- clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
+++ clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
@@ -34,19 +34,22 @@
// RV64ZBB-NEXT: [[TMP1:%.*]] = call i32 @llvm.ctlz.i32(i32 [[TMP0]], i1 false)
// RV64ZBB-NEXT: ret i32 [[TMP1]]
//
-int clz_32(int a) {
+int clz_32(unsigned int a) {
return __builtin_riscv_clz_32(a);
}
// RV64ZBB-LABEL: @clz_64(
// RV64ZBB-NEXT: entry:
+// RV64ZBB-NEXT: [[RETVAL:%.*]] = alloca i32, align 4
// RV64ZBB-NEXT: [[A_ADDR:%.*]] = alloca i64, align 8
// RV64ZBB-NEXT: store i64 [[A:%.*]], ptr [[A_ADDR]], align 8
// RV64ZBB-NEXT: [[TMP0:%.*]] = load i64, ptr [[A_ADDR]], align 8
// RV64ZBB-NEXT: [[TMP1:%.*]] = call i64 @llvm.ctlz.i64(i64 [[TMP0]], i1 false)
-// RV64ZBB-NEXT: ret i64 [[TMP1]]
+// RV64ZBB-NEXT: store i64 [[TMP1]], ptr [[RETVAL]], align 4
+// RV64ZBB-NEXT: [[TMP2:%.*]] = load i32, ptr [[RETVAL]], align 4
+// RV64ZBB-NEXT: ret i32 [[TMP2]]
//
-long clz_64(long a) {
+int clz_64(unsigned long a) {
return __builtin_riscv_clz_64(a);
}
@@ -58,18 +61,21 @@
// RV64ZBB-NEXT: [[TMP1:%.*]] = call i32 @llvm.cttz.i32(i32 [[TMP0]], i1 false)
// RV64ZBB-NEXT: ret i32 [[TMP1]]
//
-int ctz_32(int a) {
+int ctz_32(unsigned int a) {
return __builtin_riscv_ctz_32(a);
}
// RV64ZBB-LABEL: @ctz_64(
// RV64ZBB-NEXT: entry:
+// RV64ZBB-NEXT: [[RETVAL:%.*]] = alloca i32, align 4
// RV64ZBB-NEXT: [[A_ADDR:%.*]] = alloca i64, align 8
// RV64ZBB-NEXT: store i64 [[A:%.*]], ptr [[A_ADDR]], align 8
// RV64ZBB-NEXT: [[TMP0:%.*]] = load i64, ptr [[A_ADDR]], align 8
// RV64ZBB-NEXT: [[TMP1:%.*]] = call i64 @llvm.cttz.i64(i64 [[TMP0]], i1 false)
-// RV64ZBB-NEXT: ret i64 [[TMP1]]
+// RV64ZBB-NEXT: store i64 [[TMP1]], ptr [[RETVAL]], align 4
+// RV64ZBB-NEXT: [[TMP2:%.*]] = load i32, ptr [[RETVAL]], align 4
+// RV64ZBB-NEXT: ret i32 [[TMP2]]
//
-long ctz_64(long a) {
+int ctz_64(unsigned long a) {
return __builtin_riscv_ctz_64(a);
}
\ No newline at end of file
Index: clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
===================================================================
--- clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
+++ clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
@@ -22,7 +22,7 @@
// RV32ZBB-NEXT: [[TMP1:%.*]] = call i32 @llvm.ctlz.i32(i32 [[TMP0]], i1 false)
// RV32ZBB-NEXT: ret i32 [[TMP1]]
//
-int clz_32(int a) {
+int clz_32(unsigned int a) {
return __builtin_riscv_clz_32(a);
}
@@ -34,6 +34,6 @@
// RV32ZBB-NEXT: [[TMP1:%.*]] = call i32 @llvm.cttz.i32(i32 [[TMP0]], i1 false)
// RV32ZBB-NEXT: ret i32 [[TMP1]]
//
-int ctz_32(int a) {
+int ctz_32(unsigned int a) {
return __builtin_riscv_ctz_32(a);
}
\ No newline at end of file
Index: clang/include/clang/Basic/BuiltinsRISCV.def
===================================================================
--- clang/include/clang/Basic/BuiltinsRISCV.def
+++ clang/include/clang/Basic/BuiltinsRISCV.def
@@ -18,10 +18,10 @@
// Zbb extension
TARGET_BUILTIN(__builtin_riscv_orc_b_32, "ZiZi", "nc", "zbb")
TARGET_BUILTIN(__builtin_riscv_orc_b_64, "WiWi", "nc", "zbb,64bit")
-TARGET_BUILTIN(__builtin_riscv_clz_32, "ZiZi", "nc", "zbb|xtheadbb")
-TARGET_BUILTIN(__builtin_riscv_clz_64, "WiWi", "nc", "zbb|xtheadbb,64bit")
-TARGET_BUILTIN(__builtin_riscv_ctz_32, "ZiZi", "nc", "zbb")
-TARGET_BUILTIN(__builtin_riscv_ctz_64, "WiWi", "nc", "zbb,64bit")
+TARGET_BUILTIN(__builtin_riscv_clz_32, "iUZi", "nc", "zbb|xtheadbb")
+TARGET_BUILTIN(__builtin_riscv_clz_64, "iUWi", "nc", "zbb|xtheadbb,64bit")
+TARGET_BUILTIN(__builtin_riscv_ctz_32, "iUZi", "nc", "zbb")
+TARGET_BUILTIN(__builtin_riscv_ctz_64, "iUWi", "nc", "zbb,64bit")
// Zbc or Zbkc extension
TARGET_BUILTIN(__builtin_riscv_clmul, "LiLiLi", "nc", "zbc|zbkc")
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153235.534425.patch
Type: text/x-patch
Size: 3924 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230626/2e240648/attachment-0001.bin>
More information about the cfe-commits
mailing list