llvmorg-github-actions[bot] wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-amdgpu

Author: Harshit (blenbot)

<details>
<summary>Changes</summary>

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 

---
Full diff: https://github.com/llvm/llvm-project/pull/244000.diff


2 Files Affected:

- (modified) clang/lib/CIR/CodeGen/CIRGenBuiltinAMDGPU.cpp (+2-4) 
- (modified) clang/test/CIR/CodeGenHIP/builtins-amdgcn.hip (+8) 


``````````diff
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

``````````

</details>


https://github.com/llvm/llvm-project/pull/244000
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to