Refine isnan builtin.
authorYang Rong <rong.r.yang@intel.com>
Mon, 25 Nov 2013 07:08:09 +0000 (15:08 +0800)
committerZhigang Gong <zhigang.gong@intel.com>
Mon, 2 Dec 2013 04:24:10 +0000 (12:24 +0800)
Signed-off-by: Yang Rong <rong.r.yang@intel.com>
Reviewed-by: Zhigang Gong <zhigang.gong@intel.com>
backend/src/ocl_stdlib.tmpl.h

index 555c63c..851a9aa 100644 (file)
@@ -248,9 +248,7 @@ INLINE_OVERLOADABLE int isinf(float x) {
   return (u.u & 0x7FFFFFFF) == 0x7F800000;
 }
 INLINE_OVERLOADABLE int isnan(float x) {
-  union { uint u; float f; } u;
-  u.f = x;
-  return (u.u & 0x7FFFFFFF) > 0x7F800000;
+  return x != x;
 }
 INLINE_OVERLOADABLE int isnormal(float x) {
   union { uint u; float f; } u;