From b97cd93b3527b60355ce69e22585addbc8e9f4dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Thu, 8 Jul 2021 16:49:18 +0200 Subject: [PATCH] aco: fix extract_vector optimization If the allocated_vec map contains a different RegType for the elements, ensure that the size matches exactly. Otherwise, it could happen that extracting a dword element matched with a subdword element. No fossil-db changes. Reviewed-by: Rhys Perry Part-of: --- src/amd/compiler/aco_instruction_selection.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/amd/compiler/aco_instruction_selection.cpp b/src/amd/compiler/aco_instruction_selection.cpp index c7bdbb8b3c4..bcd8490f379 100644 --- a/src/amd/compiler/aco_instruction_selection.cpp +++ b/src/amd/compiler/aco_instruction_selection.cpp @@ -1329,9 +1329,8 @@ visit_alu_instr(isel_context* ctx, nir_alu_instr* instr) RegClass elem_rc = RegClass::get(RegType::vgpr, instr->dest.dest.ssa.bit_size / 8u); for (unsigned i = 0; i < num; ++i) { if (elems[i].type() == RegType::sgpr && elem_rc.is_subdword()) - vec->operands[i] = Operand(emit_extract_vector(ctx, elems[i], 0, elem_rc)); - else - vec->operands[i] = Operand{elems[i]}; + elems[i] = emit_extract_vector(ctx, elems[i], 0, elem_rc); + vec->operands[i] = Operand{elems[i]}; } vec->definitions[0] = Definition(dst); ctx->block->instructions.emplace_back(std::move(vec));