From 68616b162964456fff5ff23f8b0a38854db09231 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 5 Jul 2022 16:42:20 -0600 Subject: [PATCH] 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 Reviewed-by: Dave Airlie Reviewed-by: Roland Scheidegger Part-of: --- src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c index a7b2af8a8c6..776e95f25bf 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c @@ -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; + } } /**