[Beignet] [BUG REPORT] nested if-else not work for 64bit integer

Zhigang Gong zhigang.gong at linux.intel.com
Fri Aug 16 00:10:38 PDT 2013


Thanks for the patch and bug report. Could you take this bug?

On Fri, Aug 16, 2013 at 09:21:43AM +0800, Homer Hsing wrote:
> 64bit version "abs_diff()" uses two-level-nested if-else.
> GEN_IR is correct. But GEN_ASM may be wrong.
> 
> To reproduce the bug:
>   first apply patch "add empty 64bit-integer version built-in functions".
>   then apply this patch.
>   then in piglit, run
> bin/cl-program-tester generated_tests/cl/builtin/int/builtin-long-abs_diff-1.0.generated.cl
> 
> ---
>  backend/src/ocl_stdlib.tmpl.h | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/backend/src/ocl_stdlib.tmpl.h b/backend/src/ocl_stdlib.tmpl.h
> index 00d6fda..bcb8f1a 100644
> --- a/backend/src/ocl_stdlib.tmpl.h
> +++ b/backend/src/ocl_stdlib.tmpl.h
> @@ -507,10 +507,13 @@ INLINE_OVERLOADABLE uint abs_diff (int x, int y) {
>  }
>  
>  INLINE_OVERLOADABLE ulong abs_diff (long x, long y) {
> -  return 0;
> +    if ((x >= 0 && y >= 0) || (x <= 0 && y <= 0))
> +        return abs(x - y);
> +    return abs(x) + abs(y);
>  }
> +
>  INLINE_OVERLOADABLE ulong abs_diff (ulong x, ulong y) {
> -  return 0;
> +    return y > x ? y - x : x - y;
>  }
>  
>  /////////////////////////////////////////////////////////////////////////////
> -- 
> 1.8.1.2
> 
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/beignet


More information about the Beignet mailing list