From 6fc6e3a51a29aa126ff63d5e7a8cf7f316e419c7 Mon Sep 17 00:00:00 2001
From: psychocrypt <psychocryptHPC@gmail.com>
Date: Tue, 16 Oct 2018 16:19:48 +0200
Subject: [PATCH] fix AMD driver 14

Fix the fix from #1945. The initial fix produces invalid results.
---
 xmrstak/backend/amd/amd_gpu/opencl/fast_int_math_v2.cl | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/xmrstak/backend/amd/amd_gpu/opencl/fast_int_math_v2.cl b/xmrstak/backend/amd/amd_gpu/opencl/fast_int_math_v2.cl
index 55768d3..1ef1dea 100644
--- a/xmrstak/backend/amd/amd_gpu/opencl/fast_int_math_v2.cl
+++ b/xmrstak/backend/amd/amd_gpu/opencl/fast_int_math_v2.cl
@@ -79,8 +79,10 @@ inline uint2 fast_div_v2(const __local uint *RCP, ulong a, uint b)
 	 * https://github.com/fireice-uk/xmr-stak/issues/1922
 	 * This is a workaround for the broken compiler.
 	 */
-	const long xx = k - a;
-	((uint*)&q)[1] = (xx < 0) ? 1U : 0U;
+	 ulong whyAMDwhy;
+	((uint*)&whyAMDwhy)[0] = as_uint2(k).s0;
+	((uint*)&whyAMDwhy)[1] = as_uint2(k).s1;
+	((uint*)&q)[1] = (whyAMDwhy < a) ? 1U : 0U;
 #else
 	((uint*)&q)[1] = (k < a) ? 1U : 0U;
 #endif
-- 
GitLab