https://github.com/frasercrmck created https://github.com/llvm/llvm-project/pull/123653
The half variants were missing. The integer bitselect builtins weren't going through __clc_bitselect due to an oversight when the CLC version was introduced. >From d885c214c83bae79fa6d66c5c223e0d6ae972f3b Mon Sep 17 00:00:00 2001 From: Fraser Cormack <fra...@codeplay.com> Date: Mon, 20 Jan 2025 17:29:18 +0000 Subject: [PATCH] [libclc] Route int bitselect through CLC; add half The half variants were missing. The integer bitselect builtins weren't going through __clc_bitselect due to an oversight when the CLC version was introduced. --- .../lib/generic/relational/clc_bitselect.cl | 12 ++++++++ libclc/generic/lib/relational/bitselect.cl | 28 ++----------------- libclc/generic/lib/relational/bitselect.inc | 5 ++-- 3 files changed, 17 insertions(+), 28 deletions(-) diff --git a/libclc/clc/lib/generic/relational/clc_bitselect.cl b/libclc/clc/lib/generic/relational/clc_bitselect.cl index 66b28af71b38d3..6281eeea1abb29 100644 --- a/libclc/clc/lib/generic/relational/clc_bitselect.cl +++ b/libclc/clc/lib/generic/relational/clc_bitselect.cl @@ -53,3 +53,15 @@ FLOAT_BITSELECT(double, ulong, 8) FLOAT_BITSELECT(double, ulong, 16) #endif + +#ifdef cl_khr_fp16 +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +FLOAT_BITSELECT(half, ushort, ) +FLOAT_BITSELECT(half, ushort, 2) +FLOAT_BITSELECT(half, ushort, 3) +FLOAT_BITSELECT(half, ushort, 4) +FLOAT_BITSELECT(half, ushort, 8) +FLOAT_BITSELECT(half, ushort, 16) + +#endif diff --git a/libclc/generic/lib/relational/bitselect.cl b/libclc/generic/lib/relational/bitselect.cl index a470447f1fb91a..04aae105b7f2cf 100644 --- a/libclc/generic/lib/relational/bitselect.cl +++ b/libclc/generic/lib/relational/bitselect.cl @@ -21,34 +21,10 @@ */ #include <clc/clc.h> -#include <clc/clcmacro.h> #include <clc/relational/clc_bitselect.h> #define __CLC_BODY <bitselect.inc> #include <clc/integer/gentype.inc> -#undef __CLC_BODY -#define FLOAT_BITSELECT(f_type, i_type, width) \ - _CLC_OVERLOAD _CLC_DEF f_type##width bitselect( \ - f_type##width x, f_type##width y, f_type##width z) { \ - return __clc_bitselect(x, y, z); \ - } - -FLOAT_BITSELECT(float, uint, ) -FLOAT_BITSELECT(float, uint, 2) -FLOAT_BITSELECT(float, uint, 3) -FLOAT_BITSELECT(float, uint, 4) -FLOAT_BITSELECT(float, uint, 8) -FLOAT_BITSELECT(float, uint, 16) - -#ifdef cl_khr_fp64 -#pragma OPENCL EXTENSION cl_khr_fp64 : enable - -FLOAT_BITSELECT(double, ulong, ) -FLOAT_BITSELECT(double, ulong, 2) -FLOAT_BITSELECT(double, ulong, 3) -FLOAT_BITSELECT(double, ulong, 4) -FLOAT_BITSELECT(double, ulong, 8) -FLOAT_BITSELECT(double, ulong, 16) - -#endif +#define __CLC_BODY <bitselect.inc> +#include <clc/math/gentype.inc> diff --git a/libclc/generic/lib/relational/bitselect.inc b/libclc/generic/lib/relational/bitselect.inc index 3a78a8c7b74878..b0d64bddffdfd1 100644 --- a/libclc/generic/lib/relational/bitselect.inc +++ b/libclc/generic/lib/relational/bitselect.inc @@ -20,6 +20,7 @@ * THE SOFTWARE. */ -_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE bitselect(__CLC_GENTYPE x, __CLC_GENTYPE y, __CLC_GENTYPE z) { - return ((x) ^ ((z) & ((y) ^ (x)))); +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE bitselect(__CLC_GENTYPE x, __CLC_GENTYPE y, + __CLC_GENTYPE z) { + return __clc_bitselect(x, y, z); } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits