gallivm: fix incorrect memset() in SOA emit_load_const()

The memset() call to zero-out the unused elements of outval[] used
the wrong bytecount.  Just replace it with a simpler for loop.

Signed-off-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17561>
This commit is contained in:
Brian Paul 2022-07-05 16:42:20 -06:00 committed by Marge Bot
parent 9984ec67f2
commit 68616b1629
1 changed files with 10 additions and 3 deletions

View File

@ -1132,9 +1132,16 @@ emit_load_const(struct lp_build_nir_context *bld_base,
LLVMValueRef outval[NIR_MAX_VEC_COMPONENTS])
{
struct lp_build_context *int_bld = get_int_bld(bld_base, true, instr->def.bit_size);
for (unsigned i = 0; i < instr->def.num_components; i++)
outval[i] = lp_build_const_int_vec(bld_base->base.gallivm, int_bld->type, instr->def.bit_size == 32 ? instr->value[i].u32 : instr->value[i].u64);
memset(&outval[instr->def.num_components], 0, NIR_MAX_VEC_COMPONENTS - instr->def.num_components);
const unsigned bits = instr->def.bit_size;
for (unsigned i = 0; i < instr->def.num_components; i++) {
outval[i] = lp_build_const_int_vec(bld_base->base.gallivm, int_bld->type,
bits == 32 ? instr->value[i].u32
: instr->value[i].u64);
}
for (unsigned i = instr->def.num_components; i < NIR_MAX_VEC_COMPONENTS; i++) {
outval[i] = NULL;
}
}
/**