https://github.com/arsenm updated 
https://github.com/llvm/llvm-project/pull/185626

>From 4eaff61d6c2e130dc91ceb8d9d243d87b86e574a Mon Sep 17 00:00:00 2001
From: Matt Arsenault <[email protected]>
Date: Tue, 10 Mar 2026 12:44:49 +0100
Subject: [PATCH] libclc: Use elementwise exp for exp functions

For amdgpu use the exp intrinisc. Really, this should be
the default generic implementation. But we're stuck in a
mess where essentially nothing works. All of the exp
intrinsics work for AMDGPU, but aren't really implemented
for spirv or nvptx. Ideally the intrinsic and/or libm call
would be the default implementation.
---
 libclc/clc/lib/amdgpu/CMakeLists.txt    |  3 +++
 libclc/clc/lib/amdgpu/math/clc_exp.cl   | 15 +++++++++++++++
 libclc/clc/lib/amdgpu/math/clc_exp10.cl | 15 +++++++++++++++
 libclc/clc/lib/amdgpu/math/clc_exp2.cl  | 15 +++++++++++++++
 4 files changed, 48 insertions(+)
 create mode 100644 libclc/clc/lib/amdgpu/math/clc_exp.cl
 create mode 100644 libclc/clc/lib/amdgpu/math/clc_exp10.cl
 create mode 100644 libclc/clc/lib/amdgpu/math/clc_exp2.cl

diff --git a/libclc/clc/lib/amdgpu/CMakeLists.txt 
b/libclc/clc/lib/amdgpu/CMakeLists.txt
index cfed021d8fc26..f593bc6fdd8cf 100644
--- a/libclc/clc/lib/amdgpu/CMakeLists.txt
+++ b/libclc/clc/lib/amdgpu/CMakeLists.txt
@@ -1,6 +1,9 @@
 libclc_configure_source_list(CLC_AMDGPU_SOURCES
   ${CMAKE_CURRENT_SOURCE_DIR}
   address_space/qualifier.cl
+  math/clc_exp.cl
+  math/clc_exp2.cl
+  math/clc_exp10.cl
   math/clc_half_exp.cl
   math/clc_half_exp2.cl
   math/clc_half_exp10.cl
diff --git a/libclc/clc/lib/amdgpu/math/clc_exp.cl 
b/libclc/clc/lib/amdgpu/math/clc_exp.cl
new file mode 100644
index 0000000000000..ae82bbb3a5c61
--- /dev/null
+++ b/libclc/clc/lib/amdgpu/math/clc_exp.cl
@@ -0,0 +1,15 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "clc/math/clc_exp.h"
+
+#define __CLC_FUNCTION __clc_exp
+#define __CLC_IMPL_FUNCTION(x) __builtin_elementwise_exp
+#define __CLC_BODY <clc/shared/unary_def.inc>
+
+#include <clc/math/gentype.inc>
diff --git a/libclc/clc/lib/amdgpu/math/clc_exp10.cl 
b/libclc/clc/lib/amdgpu/math/clc_exp10.cl
new file mode 100644
index 0000000000000..b7fc6bf8cabbe
--- /dev/null
+++ b/libclc/clc/lib/amdgpu/math/clc_exp10.cl
@@ -0,0 +1,15 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "clc/math/clc_exp10.h"
+
+#define __CLC_FUNCTION __clc_exp10
+#define __CLC_IMPL_FUNCTION(x) __builtin_elementwise_exp10
+#define __CLC_BODY <clc/shared/unary_def.inc>
+
+#include <clc/math/gentype.inc>
diff --git a/libclc/clc/lib/amdgpu/math/clc_exp2.cl 
b/libclc/clc/lib/amdgpu/math/clc_exp2.cl
new file mode 100644
index 0000000000000..4b351fdd935fa
--- /dev/null
+++ b/libclc/clc/lib/amdgpu/math/clc_exp2.cl
@@ -0,0 +1,15 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "clc/math/clc_exp2.h"
+
+#define __CLC_FUNCTION __clc_exp2
+#define __CLC_IMPL_FUNCTION(x) __builtin_elementwise_exp2
+#define __CLC_BODY <clc/shared/unary_def.inc>
+
+#include <clc/math/gentype.inc>

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

Reply via email to