Blame SOURCES/mesa-10.6-llvmpipe-imm-fix-power.patch

762a8c
From 8e45b5eecce4233389bb2a50a142d37e2676c71f Mon Sep 17 00:00:00 2001
762a8c
From: Oded Gabbay <oded.gabbay@gmail.com>
762a8c
Date: Thu, 3 Sep 2015 19:00:26 +0300
762a8c
Subject: [PATCH] llvmpipe: convert double to long long instead of unsigned
762a8c
 long long
762a8c
762a8c
round(val*dscale) produces a double result, as val and dscale are double.
762a8c
However, LLVMConstInt receives unsigned long long, so there is an
762a8c
implicit conversion from double to unsigned long long.
762a8c
This is an undefined behavior. Therefore, we need to first explicitly
762a8c
convert the round result to long long, and then let the compiler handle
762a8c
conversion from that to unsigned long long.
762a8c
762a8c
This bug manifests itself in POWER, where all IMM values of -1 are being
762a8c
converted to 0 implicitly, causing a wrong LLVM IR output.
762a8c
762a8c
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
762a8c
CC: "10.6 11.0" <mesa-stable@lists.freedesktop.org>
762a8c
Reviewed-by: Tom Stellard <thomas.stellard@amd.com>
762a8c
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
762a8c
(cherry picked from commit 4f2290d1612569686284609059d29a85c9de67cf)
762a8c
---
762a8c
 src/gallium/auxiliary/gallivm/lp_bld_const.c | 2 +-
762a8c
 1 file changed, 1 insertion(+), 1 deletion(-)
762a8c
762a8c
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_const.c b/src/gallium/auxiliary/gallivm/lp_bld_const.c
762a8c
index 0f5a8f8..9cd7c55 100644
762a8c
--- a/src/gallium/auxiliary/gallivm/lp_bld_const.c
762a8c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_const.c
762a8c
@@ -311,7 +311,7 @@ lp_build_const_elem(struct gallivm_state *gallivm,
762a8c
    else {
762a8c
       double dscale = lp_const_scale(type);
762a8c
 
762a8c
-      elem = LLVMConstInt(elem_type, round(val*dscale), 0);
762a8c
+      elem = LLVMConstInt(elem_type, (long long) round(val*dscale), 0);
762a8c
    }
762a8c
 
762a8c
    return elem;
762a8c
-- 
762a8c
2.4.3
762a8c