[clang] cd8d507 - [RISCV] Pull __builtin_riscv_clz/ctz out of a nested switch. NFC
Craig Topper via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 31 11:04:33 PDT 2024
Author: Craig Topper
Date: 2024-10-31T11:01:58-07:00
New Revision: cd8d507b074e8d30f6c9925a24224673b2908a51
URL: https://github.com/llvm/llvm-project/commit/cd8d507b074e8d30f6c9925a24224673b2908a51
DIFF: https://github.com/llvm/llvm-project/commit/cd8d507b074e8d30f6c9925a24224673b2908a51.diff
LOG: [RISCV] Pull __builtin_riscv_clz/ctz out of a nested switch. NFC
The nested switch exists to share setting IntrinsicsTypes to {ResultType}.
clz/ctz return before we reach that so they can just be in the top
level switch.
Added:
Modified:
clang/lib/CodeGen/CGBuiltin.cpp
Removed:
################################################################################
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index fb721fd2be9b8e..038057d2164ced 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -22398,10 +22398,6 @@ Value *CodeGenFunction::EmitRISCVBuiltinExpr(unsigned BuiltinID,
default: llvm_unreachable("unexpected builtin ID");
case RISCV::BI__builtin_riscv_orc_b_32:
case RISCV::BI__builtin_riscv_orc_b_64:
- case RISCV::BI__builtin_riscv_clz_32:
- case RISCV::BI__builtin_riscv_clz_64:
- case RISCV::BI__builtin_riscv_ctz_32:
- case RISCV::BI__builtin_riscv_ctz_64:
case RISCV::BI__builtin_riscv_clmul_32:
case RISCV::BI__builtin_riscv_clmul_64:
case RISCV::BI__builtin_riscv_clmulh_32:
@@ -22423,24 +22419,6 @@ Value *CodeGenFunction::EmitRISCVBuiltinExpr(unsigned BuiltinID,
case RISCV::BI__builtin_riscv_orc_b_64:
ID = Intrinsic::riscv_orc_b;
break;
- case RISCV::BI__builtin_riscv_clz_32:
- case RISCV::BI__builtin_riscv_clz_64: {
- Function *F = CGM.getIntrinsic(Intrinsic::ctlz, Ops[0]->getType());
- Value *Result = Builder.CreateCall(F, {Ops[0], Builder.getInt1(false)});
- if (Result->getType() != ResultType)
- Result = Builder.CreateIntCast(Result, ResultType, /*isSigned*/true,
- "cast");
- return Result;
- }
- case RISCV::BI__builtin_riscv_ctz_32:
- case RISCV::BI__builtin_riscv_ctz_64: {
- Function *F = CGM.getIntrinsic(Intrinsic::cttz, Ops[0]->getType());
- Value *Result = Builder.CreateCall(F, {Ops[0], Builder.getInt1(false)});
- if (Result->getType() != ResultType)
- Result = Builder.CreateIntCast(Result, ResultType, /*isSigned*/true,
- "cast");
- return Result;
- }
// Zbc
case RISCV::BI__builtin_riscv_clmul_32:
@@ -22515,6 +22493,25 @@ Value *CodeGenFunction::EmitRISCVBuiltinExpr(unsigned BuiltinID,
ID = Intrinsic::riscv_sm3p1;
break;
+ case RISCV::BI__builtin_riscv_clz_32:
+ case RISCV::BI__builtin_riscv_clz_64: {
+ Function *F = CGM.getIntrinsic(Intrinsic::ctlz, Ops[0]->getType());
+ Value *Result = Builder.CreateCall(F, {Ops[0], Builder.getInt1(false)});
+ if (Result->getType() != ResultType)
+ Result =
+ Builder.CreateIntCast(Result, ResultType, /*isSigned*/ false, "cast");
+ return Result;
+ }
+ case RISCV::BI__builtin_riscv_ctz_32:
+ case RISCV::BI__builtin_riscv_ctz_64: {
+ Function *F = CGM.getIntrinsic(Intrinsic::cttz, Ops[0]->getType());
+ Value *Result = Builder.CreateCall(F, {Ops[0], Builder.getInt1(false)});
+ if (Result->getType() != ResultType)
+ Result =
+ Builder.CreateIntCast(Result, ResultType, /*isSigned*/ false, "cast");
+ return Result;
+ }
+
// Zihintntl
case RISCV::BI__builtin_riscv_ntl_load: {
llvm::Type *ResTy = ConvertType(E->getType());
More information about the cfe-commits
mailing list