[libclc] [libclc] Move several integer functions to CLC library (PR #116786)

Fraser Cormack via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 5 09:40:18 PST 2024


================
@@ -0,0 +1,21 @@
+#ifndef __CLC_INTEGER_CLC_CLZ_H__
+#define __CLC_INTEGER_CLC_CLZ_H__
+
+#if defined(CLC_CLSPV) || defined(CLC_SPIRV)
+// clspv and spir-v targets provide their own OpenCL-compatible clz
+#define __clc_clz clz
----------------
frasercrmck wrote:

> > I'm not sure why wrapping the intrinsic isn't a suitable implementation for SPIR-V targets.
> 
> I assert it must be and SPIRV must handle the intrinsic.

It seems like the SPIR-V translator is able to translate the `ctlz` intrinsic to the `OpExtInst clz` SPIR-V instruction, which seems to me to be equivalent to redirecting `__clc_clz` back to the OpenCL `clz` entry point.

In this context of this PR, what are you proposing? That no such redirections should take place, or just that ones that map to intrinsics specifically should not be redirected? I don't see how providing proper implementations for the CLC functions in this PR would be a problem for SPIR-V targets, except perhaps for adding extra code they don't end up using.

What I still don't fully understand is why the SPIR-V targets currently don't provide implementations for certain OpenCL entry points like `rhadd` or `popcount`. @karolherbst or @rjodinchr, would you be able to clarify?

https://github.com/llvm/llvm-project/pull/116786


More information about the cfe-commits mailing list