aco: fix p_extract_vector validation
authorRhys Perry <pendingchaos02@gmail.com>
Fri, 10 Apr 2020 14:11:03 +0000 (15:11 +0100)
committerMarge Bot <eric+marge@anholt.net>
Tue, 14 Apr 2020 10:49:12 +0000 (10:49 +0000)
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4507>

src/amd/compiler/aco_validate.cpp

index 39174971b04be07682e6e6229c1bf61441f584ef..3e0f4584cd3fa7beffbee6b41540fab7af37466f 100644 (file)
@@ -261,7 +261,7 @@ void validate(Program* program, FILE * output)
                }
             } else if (instr->opcode == aco_opcode::p_extract_vector) {
                check((instr->operands[0].isTemp()) && instr->operands[1].isConstant(), "Wrong Operand types", instr.get());
-               check(instr->operands[1].constantValue() < instr->operands[0].size(), "Index out of range", instr.get());
+               check((instr->operands[1].constantValue() + 1) * instr->definitions[0].bytes() <= instr->operands[0].bytes(), "Index out of range", instr.get());
                check(instr->definitions[0].getTemp().type() == RegType::vgpr || instr->operands[0].regClass().type() == RegType::sgpr,
                      "Cannot extract SGPR value from VGPR vector", instr.get());
             } else if (instr->opcode == aco_opcode::p_parallelcopy) {