[libclc] r326817 - maxmag: Condition variable needs to be the same bitwidth as operands

Jan Vesely via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 6 09:48:38 PST 2018


Author: jvesely
Date: Tue Mar  6 09:48:38 2018
New Revision: 326817

URL: http://llvm.org/viewvc/llvm-project?rev=326817&view=rev
Log:
maxmag: Condition variable needs to be the same bitwidth as operands

No changes wrt CTS

Reviewed-by: Aaron Watry <awatry at gmail.com>
Signed-off-by: Jan Vesely <jan.vesely at rutgers.edu>

Modified:
    libclc/trunk/generic/lib/math/maxmag.cl
    libclc/trunk/generic/lib/math/maxmag.inc

Modified: libclc/trunk/generic/lib/math/maxmag.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/maxmag.cl?rev=326817&r1=326816&r2=326817&view=diff
==============================================================================
--- libclc/trunk/generic/lib/math/maxmag.cl (original)
+++ libclc/trunk/generic/lib/math/maxmag.cl Tue Mar  6 09:48:38 2018
@@ -1,4 +1,5 @@
 #include <clc/clc.h>
+#include <utils.h>
 
 #define __CLC_BODY <maxmag.inc>
 #include <clc/math/gentype.inc>

Modified: libclc/trunk/generic/lib/math/maxmag.inc
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/maxmag.inc?rev=326817&r1=326816&r2=326817&view=diff
==============================================================================
--- libclc/trunk/generic/lib/math/maxmag.inc (original)
+++ libclc/trunk/generic/lib/math/maxmag.inc Tue Mar  6 09:48:38 2018
@@ -1,4 +1,22 @@
+#ifdef __CLC_SCALAR
+#define __CLC_VECSIZE
+#endif
+
+#if __CLC_FPSIZE == 64
+#define __CLC_CONVERT_NATN __CLC_XCONCAT(convert_long, __CLC_VECSIZE)
+#elif __CLC_FPSIZE == 32
+#define __CLC_CONVERT_NATN __CLC_XCONCAT(convert_int, __CLC_VECSIZE)
+#elif __CLC_FPSIZE == 16
+#define __CLC_CONVERT_NATN __CLC_XCONCAT(convert_short, __CLC_VECSIZE)
+#endif
+
 _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE maxmag(__CLC_GENTYPE x, __CLC_GENTYPE y) {
-  const __CLC_GENTYPE res = select(y, x, isgreater(fabs(x), fabs(y)));
-  return select(res, fmax(x, y), isnan(x) | isnan(y) | isequal(fabs(x), fabs(y)));
+  const __CLC_GENTYPE res = select(y, x, __CLC_CONVERT_NATN(isgreater(fabs(x), fabs(y))));
+  return select(res, fmax(x, y), __CLC_CONVERT_NATN(isnan(x) | isnan(y) | isequal(fabs(x), fabs(y))));
 }
+
+#undef __CLC_CONVERT_NATN
+
+#ifdef __CLC_SCALAR
+#undef __CLC_VECSIZE
+#endif




More information about the cfe-commits mailing list