if an parameter is nan, then returns another parameter.

Signed-off-by: Homer Hsing <[email protected]>
---
 backend/src/ocl_stdlib.tmpl.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/backend/src/ocl_stdlib.tmpl.h b/backend/src/ocl_stdlib.tmpl.h
index bff2b1c..ec9ed60 100644
--- a/backend/src/ocl_stdlib.tmpl.h
+++ b/backend/src/ocl_stdlib.tmpl.h
@@ -1621,6 +1621,10 @@ INLINE_OVERLOADABLE float step(float edge, float x) {
 
 #define DECL_MIN_MAX_CLAMP(TYPE) \
 INLINE_OVERLOADABLE TYPE max(TYPE a, TYPE b) { \
+  if (isnan(a)) \
+    return b; \
+  if (isnan(b)) \
+    return a; \
   return a > b ? a : b; \
 } \
 INLINE_OVERLOADABLE TYPE min(TYPE a, TYPE b) { \
-- 
1.8.3.2

_______________________________________________
Beignet mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/beignet

Reply via email to