From 0ad65f2c55623e8578c39c5837e357f5566780cf Mon Sep 17 00:00:00 2001 From: =?utf8?q?Timur=20Krist=C3=B3f?= Date: Thu, 26 Mar 2020 12:19:32 +0100 Subject: [PATCH] aco: Zero-fill undefined elements in create_vec_from_array. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Timur Kristóf Reviewed-by: Rhys Perry Part-of: --- .../compiler/aco_instruction_selection.cpp | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/amd/compiler/aco_instruction_selection.cpp b/src/amd/compiler/aco_instruction_selection.cpp index fa31149bf50..4ec971e4d6c 100644 --- a/src/amd/compiler/aco_instruction_selection.cpp +++ b/src/amd/compiler/aco_instruction_selection.cpp @@ -2900,21 +2900,29 @@ unsigned calculate_lds_alignment(isel_context *ctx, unsigned const_offset) } -Temp create_vec_from_array(isel_context *ctx, Temp arr[], unsigned cnt, RegType reg_type, unsigned split_cnt = 0u, Temp dst = Temp()) +Temp create_vec_from_array(isel_context *ctx, Temp arr[], unsigned cnt, RegType reg_type, unsigned elem_size_bytes, + unsigned split_cnt = 0u, Temp dst = Temp()) { Builder bld(ctx->program, ctx->block); + unsigned dword_size = elem_size_bytes / 4; if (!dst.id()) - dst = bld.tmp(RegClass(reg_type, cnt * arr[0].size())); + dst = bld.tmp(RegClass(reg_type, cnt * dword_size)); std::array allocated_vec; aco_ptr instr {create_instruction(aco_opcode::p_create_vector, Format::PSEUDO, cnt, 1)}; instr->definitions[0] = Definition(dst); for (unsigned i = 0; i < cnt; ++i) { - assert(arr[i].size() == arr[0].size()); - allocated_vec[i] = arr[i]; - instr->operands[i] = Operand(arr[i]); + if (arr[i].id()) { + assert(arr[i].size() == dword_size); + allocated_vec[i] = arr[i]; + instr->operands[i] = Operand(arr[i]); + } else { + Temp zero = bld.copy(bld.def(RegClass(reg_type, dword_size)), Operand(0u, dword_size == 2)); + allocated_vec[i] = zero; + instr->operands[i] = Operand(zero); + } } bld.insert(std::move(instr)); @@ -3065,7 +3073,7 @@ void load_vmem_mubuf(isel_context *ctx, Temp dst, Temp descriptor, Temp voffset, elems[i] = emit_single_mubuf_load(ctx, descriptor, voffset, soffset, const_offset, load_size, allow_reorder); } - create_vec_from_array(ctx, elems.data(), num_loads, RegType::vgpr, split_cnt, dst); + create_vec_from_array(ctx, elems.data(), num_loads, RegType::vgpr, load_size * 4u, split_cnt, dst); } std::pair offset_add_from_nir(isel_context *ctx, const std::pair &base_offset, nir_src *off_src, unsigned stride = 1u) @@ -9428,7 +9436,7 @@ static void write_tcs_tess_factors(isel_context *ctx) } assert(stride == 2 || stride == 4 || stride == 6); - Temp tf_vec = create_vec_from_array(ctx, out, stride, RegType::vgpr); + Temp tf_vec = create_vec_from_array(ctx, out, stride, RegType::vgpr, 4u); store_vmem_mubuf(ctx, tf_vec, hs_ring_tess_factor, byte_offset, tf_base, tf_const_offset, 4, (1 << stride) - 1, true, false); /* Store to offchip for TES to read - only if TES reads them */ -- 2.30.2