[clang] [CIR][AMDGPU] Add support for __builtin_amdgcn_log_clampf (PR #244000)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 18 12:51:09 PST 2026
https://github.com/blenbot created https://github.com/llvm/llvm-project/pull/244000
Adds CIRGen support for `__builtin_amdgcn_log_clampf`, also adds CIR and LLVM IR test coverage in `clang/test/CIR/CodeGenHIP/builtins-amdgcn.hip`.
Part of #241525
>From 43c2229fa37e1d2c6f35c8baa909e91ffbcfd9dd Mon Sep 17 00:00:00 2001
From: Harshit Jha <harshitiszz23 at gmail.com>
Date: Wed, 18 Nov 2026 20:42:42 +0000
Subject: [PATCH] Add support for __builtin_amdgcn_log_clampf
Signed-off-by: Harshit Jha <harshitiszz23 at gmail.com>
---
clang/lib/CIR/CodeGen/CIRGenBuiltinAMDGPU.cpp | 6 ++----
clang/test/CIR/CodeGenHIP/builtins-amdgcn.hip | 8 ++++++++
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/clang/lib/CIR/CodeGen/CIRGenBuiltinAMDGPU.cpp b/clang/lib/CIR/CodeGen/CIRGenBuiltinAMDGPU.cpp
index 1654f36851d15..b5a98cf92c289 100644
--- a/clang/lib/CIR/CodeGen/CIRGenBuiltinAMDGPU.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenBuiltinAMDGPU.cpp
@@ -626,10 +626,8 @@ CIRGenFunction::emitAMDGPUBuiltinExpr(unsigned builtinId,
return emitBuiltinWithOneOverloadedType<1>(expr, "amdgcn.exp2").getValue();
}
case AMDGPU::BI__builtin_amdgcn_log_clampf: {
- cgm.errorNYI(expr->getSourceRange(),
- std::string("unimplemented AMDGPU builtin call: ") +
- getContext().BuiltinInfo.getName(builtinId));
- return mlir::Value{};
+ return emitBuiltinWithOneOverloadedType<1>(expr, "amdgcn.log.clamp")
+ .getValue();
}
case AMDGPU::BI__builtin_amdgcn_ldexp:
case AMDGPU::BI__builtin_amdgcn_ldexpf:
diff --git a/clang/test/CIR/CodeGenHIP/builtins-amdgcn.hip b/clang/test/CIR/CodeGenHIP/builtins-amdgcn.hip
index 83b2f955fd8c6..73095a0545d2f 100644
--- a/clang/test/CIR/CodeGenHIP/builtins-amdgcn.hip
+++ b/clang/test/CIR/CodeGenHIP/builtins-amdgcn.hip
@@ -252,6 +252,14 @@ __device__ void test_log_f32(float* out, float a) {
*out = __builtin_amdgcn_logf(a);
}
+// CIR-LABEL: @_Z18test_log_clamp_f32Pff
+// CIR: cir.call_llvm_intrinsic "amdgcn.log.clamp" {{.*}} : (!cir.float) -> !cir.float
+// LLVM: define{{.*}} void @_Z18test_log_clamp_f32Pff
+// LLVM: call{{.*}} float @llvm.amdgcn.log.clamp.f32(float %{{.*}})
+__device__ void test_log_clamp_f32(float* out, float a) {
+ *out = __builtin_amdgcn_log_clampf(a);
+}
+
// CIR-LABEL: @_Z19test_frexp_mant_f32Pff
// CIR: cir.call_llvm_intrinsic "amdgcn.frexp.mant" {{.*}} : (!cir.float) -> !cir.float
// LLVM: define{{.*}} void @_Z19test_frexp_mant_f32Pff
More information about the cfe-commits
mailing list