[PATCH] D124348: [1/2][RISCV]Add Intrinsics for B extension in Clang
Craig Topper via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Apr 24 12:24:02 PDT 2022
craig.topper added a comment.
The "B extension" terminology no longer exists.
================
Comment at: clang/include/clang/Basic/BuiltinsRISCV.def:29
+TARGET_BUILTIN(__builtin_riscv_cpopw_64, "WiWi", "nc", "zbb,64bit")
+TARGET_BUILTIN(__builtin_riscv_ctz_32, "ZiZi", "nc", "zbb")
+TARGET_BUILTIN(__builtin_riscv_ctz_64, "WiWi", "nc", "zbb,64bit")
----------------
The only ones of these we need is ctz_32 and ctz_64 and they should be implemented the same as clz_32/clz_64.
I guess we might also need max_32/max_64/maxu_32/maxu_64/min_32/min_64/minu_32/minu_64 for -O0. For -O1 and above `(x > y) ? x : y` already works. They can use the existing llvm.smax/smin/umax/umin intrinsics.
andn can be represented directly in C with X & ~Y
orn is X | ~Y
cpop_32 is __builtin_popcount
cpop_64 is __builtin_popcountll
clzw_32 is __builtin_riscv_clz_32 sign extended to 64 bits. Similar for ctzw_64.
================
Comment at: llvm/include/llvm/IR/IntrinsicsRISCV.td:90
def int_riscv_orc_b : BitManipGPRIntrinsics;
+ def int_riscv_andn : BitManipGPRGPRGRIntrinsics;
+ def int_riscv_clzw : BitManipGPRIntrinsics;
----------------
We don't need any of these intrinsics.
Max already has llvm.smax and llvm.umax.
clzw is (signext (llvm.cltz))
cpop is llvm.ctpop
cpopw is (signext (llvm.ctpop))
andn is (and X, (not Y))
orn is (or X, (not Y))
ctz is llvm.ctlz
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D124348/new/
https://reviews.llvm.org/D124348
More information about the cfe-commits
mailing list