[libclc] [libclc] Add __clc_nan implementation with signed nancode argument (PR #146485)

Wenju He via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 1 01:22:22 PDT 2025


https://github.com/wenju-he created https://github.com/llvm/llvm-project/pull/146485

In OpenCL Extended Instruction Set Specificatio, nancode can be signed integer or vector of signed integers values.
This PR has no change to amdgcn--amdhsa.bc and nvptx64--nvidiacl.bc because the newly added clc functions are no used in OpenCL library.

>From 7ba65b7355d6939ce6da9d771ce8ed56a07f9d75 Mon Sep 17 00:00:00 2001
From: Wenju He <wenju.he at intel.com>
Date: Tue, 1 Jul 2025 10:11:18 +0200
Subject: [PATCH] [libclc] Add __clc_nan implementation with signed nancode
 argument

In OpenCL Extended Instruction Set Specificatio, nancode can be signed
integer or vector of signed integers values.
This PR has no change to amdgcn--amdhsa.bc and nvptx64--nvidiacl.bc
because the newly added clc functions are no used in OpenCL library.
---
 libclc/clc/include/clc/math/clc_nan.inc | 1 +
 libclc/clc/lib/generic/math/clc_nan.inc | 4 ++++
 2 files changed, 5 insertions(+)

diff --git a/libclc/clc/include/clc/math/clc_nan.inc b/libclc/clc/include/clc/math/clc_nan.inc
index 637928f0839fd..22604e0a5785e 100644
--- a/libclc/clc/include/clc/math/clc_nan.inc
+++ b/libclc/clc/include/clc/math/clc_nan.inc
@@ -7,3 +7,4 @@
 //===----------------------------------------------------------------------===//
 
 _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_nan(__CLC_U_GENTYPE code);
+_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_nan(__CLC_S_GENTYPE code);
diff --git a/libclc/clc/lib/generic/math/clc_nan.inc b/libclc/clc/lib/generic/math/clc_nan.inc
index e934416351db1..46e828ba48c7e 100644
--- a/libclc/clc/lib/generic/math/clc_nan.inc
+++ b/libclc/clc/lib/generic/math/clc_nan.inc
@@ -20,4 +20,8 @@ _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_nan(__CLC_U_GENTYPE code) {
   return __CLC_AS_GENTYPE(res);
 }
 
+_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_nan(__CLC_S_GENTYPE code) {
+  return __clc_nan(__CLC_AS_U_GENTYPE(code));
+}
+
 #undef NAN_MASK



More information about the cfe-commits mailing list