gallivm: fix lp_build_compare_ext
authorRoland Scheidegger <sroland@vmware.com>
Sat, 4 Jul 2015 01:03:33 +0000 (03:03 +0200)
committerRoland Scheidegger <sroland@vmware.com>
Mon, 6 Jul 2015 21:52:32 +0000 (23:52 +0200)
The expansion should always be to the same width as the input arguments
no matter what, since these functions should work with any bit width of
the arguments (the sext is a no-op on any sane simd architecture).
Thus, fix the caller expecting differently.

This fixes https://bugs.freedesktop.org/show_bug.cgi?id=91222

Tested-by: Vinson Lee <vlee@freedesktop.org>
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
src/gallium/auxiliary/gallivm/lp_bld_logic.c
src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c

index f724cfa46eae54a4a74e9e66895add17e6814cb2..80b53e5c3f896c517d63c5635aa373d4bde317eb 100644 (file)
@@ -81,7 +81,7 @@ lp_build_compare_ext(struct gallivm_state *gallivm,
                      boolean ordered)
 {
    LLVMBuilderRef builder = gallivm->builder;
-   LLVMTypeRef int_vec_type = lp_build_int_vec_type(gallivm, lp_type_int_vec(32, 32 * type.length));
+   LLVMTypeRef int_vec_type = lp_build_int_vec_type(gallivm, type);
    LLVMValueRef zeros = LLVMConstNull(int_vec_type);
    LLVMValueRef ones = LLVMConstAllOnes(int_vec_type);
    LLVMValueRef cond;
index 1f2af85c92bc1badf49a336b6b20e78be19e63be..0ad78b0ace2ff2f5beb5332a83e56d0e1d17a2a1 100644 (file)
@@ -1961,8 +1961,11 @@ dset_emit_cpu(
    struct lp_build_emit_data * emit_data,
    unsigned pipe_func)
 {
+   LLVMBuilderRef builder = bld_base->base.gallivm->builder;
    LLVMValueRef cond = lp_build_cmp(&bld_base->dbl_bld, pipe_func,
                                     emit_data->args[0], emit_data->args[1]);
+   /* arguments were 64 bit but store as 32 bit */
+   cond = LLVMBuildTrunc(builder, cond, bld_base->int_bld.int_vec_type, "");
    emit_data->output[emit_data->chan] = cond;
 }