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 <timur.kristof@gmail.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6436>
This commit is contained in:
Timur Kristóf 2020-08-22 20:45:54 +02:00
parent 0d194a70c6
commit f820dde201

View file

@ -238,6 +238,10 @@ aco_ptr<Instruction> convert_to_SDWA(chip_class chip, aco_ptr<Instruction>& 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;