summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary
diff options
context:
space:
mode:
authorOded Gabbay <[email protected]>2015-09-03 19:00:26 +0300
committerIlia Mirkin <[email protected]>2015-09-04 17:37:17 -0400
commit4f2290d1612569686284609059d29a85c9de67cf (patch)
tree29990e7132574b3904cf57e6524f3a6c91eda315 /src/gallium/auxiliary
parent3c6c4d4f298ec81fe57992790a68aaab2e573519 (diff)
llvmpipe: convert double to long long instead of unsigned long long
round(val*dscale) produces a double result, as val and dscale are double. However, LLVMConstInt receives unsigned long long, so there is an implicit conversion from double to unsigned long long. This is an undefined behavior. Therefore, we need to first explicitly convert the round result to long long, and then let the compiler handle conversion from that to unsigned long long. This bug manifests itself in POWER, where all IMM values of -1 are being converted to 0 implicitly, causing a wrong LLVM IR output. Signed-off-by: Oded Gabbay <[email protected]> CC: "10.6 11.0" <[email protected]> Reviewed-by: Tom Stellard <[email protected]> Reviewed-by: Roland Scheidegger <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_const.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_const.c b/src/gallium/auxiliary/gallivm/lp_bld_const.c
index 0f5a8f8e851..9cd7c5553cf 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_const.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_const.c
@@ -311,7 +311,7 @@ lp_build_const_elem(struct gallivm_state *gallivm,
else {
double dscale = lp_const_scale(type);
- elem = LLVMConstInt(elem_type, round(val*dscale), 0);
+ elem = LLVMConstInt(elem_type, (long long) round(val*dscale), 0);
}
return elem;