From 6678b34284d36f11f66671ecd7dfbbd91ae87c1b Mon Sep 17 00:00:00 2001 From: Homer Hsing Date: Tue, 3 Sep 2013 08:41:28 +0800 Subject: [PATCH] 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 --- backend/src/ocl_stdlib.tmpl.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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); \ -- 2.7.4