From: Homer Hsing Date: Tue, 3 Sep 2013 00:41:28 +0000 (+0800) Subject: fix 32-bit signed version of "sub_sat" X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6678b34284d36f11f66671ecd7dfbbd91ae87c1b;p=contrib%2Fbeignet.git fix 32-bit signed version of "sub_sat" This patch makes following piglit test case pass. piglit/framework/../bin/cl-program-tester generated_tests/cl/builtin/int/builtin-int-sub_sat-1.0.generated.cl Signed-off-by: Homer Hsing Reviewed-by: Zhigang Gong --- diff --git a/backend/src/ocl_stdlib.tmpl.h b/backend/src/ocl_stdlib.tmpl.h index ba4f65c..2a20ee6 100644 --- a/backend/src/ocl_stdlib.tmpl.h +++ b/backend/src/ocl_stdlib.tmpl.h @@ -182,9 +182,14 @@ INLINE_OVERLOADABLE TYPE add_sat(TYPE x, TYPE y) { return ocl_sadd_sat(x, y); } INLINE_OVERLOADABLE TYPE sub_sat(TYPE x, TYPE y) { return ocl_ssub_sat(x, y); } SDEF(char); SDEF(short); -SDEF(int); SDEF(long); #undef SDEF +OVERLOADABLE int ocl_sadd_sat(int x, int y); +INLINE_OVERLOADABLE int add_sat(int x, int y) { return ocl_sadd_sat(x, y); } +OVERLOADABLE int ocl_ssub_sat(int x, int y); +INLINE_OVERLOADABLE int sub_sat(int x, int y) { + return (y == 0x80000000u) ? (x & 0x7FFFFFFF) : ocl_ssub_sat(x, y); +} #define UDEF(TYPE) \ OVERLOADABLE TYPE ocl_uadd_sat(TYPE x, TYPE y); \ OVERLOADABLE TYPE ocl_usub_sat(TYPE x, TYPE y); \