From: Simon Richter Date: Mon, 22 Apr 2013 16:29:57 +0000 (+0200) Subject: Add missing select() overloads X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=62d5f27eddd922b61fa4081b6b46ab8f655619cb;p=contrib%2Fbeignet.git Add missing select() overloads Both signed and unsigned types are allowed as the condition type, regardless of the true/false branch types. Signed-off-by: Simon Richter --- diff --git a/backend/src/ocl_stdlib.h b/backend/src/ocl_stdlib.h index c5ad01d..ce0c5f9 100644 --- a/backend/src/ocl_stdlib.h +++ b/backend/src/ocl_stdlib.h @@ -438,15 +438,24 @@ INLINE OVERLOADABLE float mad(float a, float b, float c) { return a*b+c; } +INLINE OVERLOADABLE uint select(uint src0, uint src1, int cond) { + return cond ? src1 : src0; +} INLINE OVERLOADABLE uint select(uint src0, uint src1, uint cond) { return cond ? src1 : src0; } INLINE OVERLOADABLE int select(int src0, int src1, int cond) { return cond ? src1 : src0; } +INLINE OVERLOADABLE int select(int src0, int src1, uint cond) { + return cond ? src1 : src0; +} INLINE OVERLOADABLE float select(float src0, float src1, int cond) { return cond ? src1 : src0; } +INLINE OVERLOADABLE float select(float src0, float src1, uint cond) { + return cond ? src1 : src0; +} // This will be optimized out by LLVM and will output LLVM select instructions #define DECL_SELECT4(TYPE4, TYPE, COND_TYPE4, MASK) \ @@ -467,7 +476,9 @@ INLINE OVERLOADABLE TYPE4 select(TYPE4 src0, TYPE4 src1, COND_TYPE4 cond) { \ return dst; \ } DECL_SELECT4(int4, int, int4, 0x80000000) +DECL_SELECT4(int4, int, uint4, 0x80000000) DECL_SELECT4(float4, float, int4, 0x80000000) +DECL_SELECT4(float4, float, uint4, 0x80000000) #undef DECL_SELECT4 /////////////////////////////////////////////////////////////////////////////