[libclc] [libclc] Move min/max/clamp into the CLC builtins library (PR #114386)

Fraser Cormack via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 31 09:04:51 PDT 2024


================
@@ -0,0 +1,11 @@
+_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_max(__CLC_GENTYPE a,
+                                               __CLC_GENTYPE b) {
+  return (a > b ? a : b);
+}
+
+#ifndef __CLC_SCALAR
+_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_max(__CLC_GENTYPE a,
+                                               __CLC_SCALAR_GENTYPE b) {
+  return (a > (__CLC_GENTYPE)b ? a : (__CLC_GENTYPE)b);
+}
+#endif
----------------
frasercrmck wrote:

Good idea, seems like a sensible refactor while we're at it. I'm generally just copy/pasting code over to try and affect as little as possible.

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


More information about the cfe-commits mailing list