From: Timur Kristóf Date: Sat, 22 Aug 2020 18:45:54 +0000 (+0200) Subject: aco: Fix convert_to_SDWA when instruction has 3 operands. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f820dde201f82763b5165dfe6516f20e9c80795b;p=mesa.git aco: Fix convert_to_SDWA when instruction has 3 operands. 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: --- 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;