From f820dde201f82763b5165dfe6516f20e9c80795b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Timur=20Krist=C3=B3f?= Date: Sat, 22 Aug 2020 20:45:54 +0200 Subject: [PATCH] aco: Fix convert_to_SDWA when instruction has 3 operands. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Previously, when the instruction had 3 operands, this would cause possible corruption because of writing to sdwa->sel[2]. This was noticed thanks to GCC 10's -Wstringop-overflow warning. Signed-off-by: Timur Kristóf Reviewed-by: Daniel Schürmann Part-of: --- src/amd/compiler/aco_ir.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/amd/compiler/aco_ir.cpp b/src/amd/compiler/aco_ir.cpp index 801fbc68616..b594b2824e9 100644 --- a/src/amd/compiler/aco_ir.cpp +++ b/src/amd/compiler/aco_ir.cpp @@ -238,6 +238,10 @@ aco_ptr convert_to_SDWA(chip_class chip, aco_ptr& inst } for (unsigned i = 0; i < instr->operands.size(); i++) { + /* SDWA only uses operands 0 and 1. */ + if (i >= 2) + break; + switch (instr->operands[i].bytes()) { case 1: sdwa->sel[i] = sdwa_ubyte; -- 2.30.2