summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/gallivm
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2010-03-15 10:29:04 -0600
committerBrian Paul <[email protected]>2010-03-15 10:29:10 -0600
commitf9d753787e6c566d3481cca07dee939239eb7071 (patch)
tree1c06ece2af7ae79f2f5cf778d56612830759d57e /src/gallium/auxiliary/gallivm
parent50d96f741e59678a19dd3308d532add1350ad441 (diff)
gallivm: fix incorrect floor(), itrunc()
LLVMBuildFPTrunc() should be used for double->float conversion, not float->int conversion. There should be a better way to compute floor(), ceil(), etc that doesn't involve float->int->float conversion.
Diffstat (limited to 'src/gallium/auxiliary/gallivm')
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_arit.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.c b/src/gallium/auxiliary/gallivm/lp_bld_arit.c
index aa47338b323..c39b062d10e 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_arit.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.c
@@ -930,7 +930,10 @@ lp_build_floor(struct lp_build_context *bld,
assert(type.floating);
if (type.length == 1) {
- return LLVMBuildFPTrunc(bld->builder, a, LLVMFloatType(), "");
+ LLVMValueRef res;
+ res = lp_build_ifloor(bld, a);
+ res = LLVMBuildSIToFP(bld->builder, res, LLVMFloatType(), "");
+ return res;
}
if(util_cpu_caps.has_sse4_1)
@@ -993,7 +996,7 @@ lp_build_itrunc(struct lp_build_context *bld,
if (type.length == 1) {
LLVMTypeRef int_type = LLVMIntType(type.width);
- return LLVMBuildFPTrunc(bld->builder, a, int_type, "");
+ return LLVMBuildFPToSI(bld->builder, a, int_type, "");
}
else {
LLVMTypeRef int_vec_type = lp_build_int_vec_type(type);