diff options
author | James Benton <jbenton@vmware.com> | 2012-05-18 16:04:49 +0100 |
---|---|---|
committer | José Fonseca <jfonseca@vmware.com> | 2012-05-21 20:24:46 +0100 |
commit | fdeb0394cbc737cefa36c6bf99cbd255d8899a9f (patch) | |
tree | 15c1351b4c52959e7269b389e37ea3ba40744625 /src/gallium/auxiliary/gallivm/lp_bld_conv.c | |
parent | f89b1f4ba4c7b13458532d916677aea3a66647dd (diff) | |
download | external_mesa3d-fdeb0394cbc737cefa36c6bf99cbd255d8899a9f.zip external_mesa3d-fdeb0394cbc737cefa36c6bf99cbd255d8899a9f.tar.gz external_mesa3d-fdeb0394cbc737cefa36c6bf99cbd255d8899a9f.tar.bz2 |
gallivm: Compensate for lp_const_offset in lp_build_conv.
Fixing a /*FIXME*/ to remove errors in integer conversion in lp_build_conv.
Tested using lp_test_conv and lp_test_format, reduced errors.
Signed-off-by: José Fonseca <jfonseca@vmware.com>
Diffstat (limited to 'src/gallium/auxiliary/gallivm/lp_bld_conv.c')
-rw-r--r-- | src/gallium/auxiliary/gallivm/lp_bld_conv.c | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_conv.c b/src/gallium/auxiliary/gallivm/lp_bld_conv.c index f0ef516..9c78460 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_conv.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_conv.c @@ -473,8 +473,23 @@ lp_build_conv(struct gallivm_state *gallivm, else { unsigned src_shift = lp_const_shift(src_type); unsigned dst_shift = lp_const_shift(dst_type); + unsigned src_offset = lp_const_offset(src_type); + unsigned dst_offset = lp_const_offset(dst_type); + + /* Compensate for different offsets */ + if (dst_offset > src_offset && src_type.width > dst_type.width) { + for (i = 0; i < num_tmps; ++i) { + LLVMValueRef shifted; + LLVMValueRef shift = lp_build_const_int_vec(gallivm, tmp_type, src_shift - 1); + if(src_type.sign) + shifted = LLVMBuildAShr(builder, tmp[i], shift, ""); + else + shifted = LLVMBuildLShr(builder, tmp[i], shift, ""); + + tmp[i] = LLVMBuildSub(builder, tmp[i], shifted, ""); + } + } - /* FIXME: compensate different offsets too */ if(src_shift > dst_shift) { LLVMValueRef shift = lp_build_const_int_vec(gallivm, tmp_type, src_shift - dst_shift); @@ -554,12 +569,24 @@ lp_build_conv(struct gallivm_state *gallivm, else { unsigned src_shift = lp_const_shift(src_type); unsigned dst_shift = lp_const_shift(dst_type); + unsigned src_offset = lp_const_offset(src_type); + unsigned dst_offset = lp_const_offset(dst_type); - /* FIXME: compensate different offsets too */ - if(src_shift < dst_shift) { + if (src_shift < dst_shift) { + LLVMValueRef pre_shift[LP_MAX_VECTOR_LENGTH]; LLVMValueRef shift = lp_build_const_int_vec(gallivm, tmp_type, dst_shift - src_shift); - for(i = 0; i < num_tmps; ++i) + + for (i = 0; i < num_tmps; ++i) { + pre_shift[i] = tmp[i]; tmp[i] = LLVMBuildShl(builder, tmp[i], shift, ""); + } + + /* Compensate for different offsets */ + if (dst_offset > src_offset) { + for (i = 0; i < num_tmps; ++i) { + tmp[i] = LLVMBuildSub(builder, tmp[i], pre_shift[i], ""); + } + } } } |