Add missing select() overloads
authorSimon Richter <Simon.Richter@hogyros.de>
Mon, 22 Apr 2013 16:29:57 +0000 (18:29 +0200)
committerZhigang Gong <zhigang.gong@linux.intel.com>
Wed, 24 Apr 2013 07:53:11 +0000 (15:53 +0800)
Both signed and unsigned types are allowed as the condition type,
regardless of the true/false branch types.

Signed-off-by: Simon Richter <Simon.Richter@hogyros.de>
backend/src/ocl_stdlib.h

index c5ad01d..ce0c5f9 100644 (file)
@@ -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
 
 /////////////////////////////////////////////////////////////////////////////