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

Homer Hsing homer.xing at intel.com
Thu Aug 15 18:21:43 PDT 2013


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



More information about the Beignet mailing list