[libclc] [libclc] add ctz built-in implementation to clc and generic (PR #135309)

Fraser Cormack via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 14 02:32:21 PDT 2025


================
@@ -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/clc.h>
+#include <clc/integer/clc_ctz.h>
+
+#define FUNCTION ctz
----------------
frasercrmck wrote:

Note the OpenCL builtin requires support for OpenCL 2.0 or newer. We should guard for that.

I think we can probably unconditionally include & compile the CLC `__clc_ctz` builtin so that we can use it internally if we wanted to, but we shouldn't include `ctz` in the OpenCL layer for OpenCL 1.X.

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


More information about the cfe-commits mailing list