From e394ff9b5f8da5a9579d0a96c371cec814caf10c Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Mon, 7 Sep 2020 20:45:25 +0100 Subject: [PATCH] aco: fix validation of sub-dword parallel-copies MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Only the operands with a sub-dword definition need to be checked. Signed-off-by: Rhys Perry Reviewed-by: Daniel Schürmann Part-of: --- src/amd/compiler/aco_validate.cpp | 43 ++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/src/amd/compiler/aco_validate.cpp b/src/amd/compiler/aco_validate.cpp index fce0e1a..02852d6 100644 --- a/src/amd/compiler/aco_validate.cpp +++ b/src/amd/compiler/aco_validate.cpp @@ -323,23 +323,34 @@ bool validate_ir(Program* program) switch (instr->format) { case Format::PSEUDO: { - bool is_subdword = false; - bool has_const_sgpr = false; - bool has_literal = false; - for (Definition def : instr->definitions) - is_subdword |= def.regClass().is_subdword(); - for (unsigned i = 0; i < instr->operands.size(); i++) { - if (instr->opcode == aco_opcode::p_extract_vector && i == 1) - continue; - Operand op = instr->operands[i]; - is_subdword |= op.hasRegClass() && op.regClass().is_subdword(); - has_const_sgpr |= op.isConstant() || (op.hasRegClass() && op.regClass().type() == RegType::sgpr); - has_literal |= op.isLiteral(); - } + if (instr->opcode == aco_opcode::p_parallelcopy) { + for (unsigned i = 0; i < instr->operands.size(); i++) { + if (!instr->definitions[i].regClass().is_subdword()) + continue; + Operand op = instr->operands[i]; + check(!op.isLiteral(), "Sub-dword copies cannot take literals", instr.get()); + if (op.isConstant() || (op.hasRegClass() && op.regClass().type() == RegType::sgpr)) + check(program->chip_class >= GFX9, "Sub-dword pseudo instructions can only take constants or SGPRs on GFX9+", instr.get()); + } + } else { + bool is_subdword = false; + bool has_const_sgpr = false; + bool has_literal = false; + for (Definition def : instr->definitions) + is_subdword |= def.regClass().is_subdword(); + for (unsigned i = 0; i < instr->operands.size(); i++) { + if (instr->opcode == aco_opcode::p_extract_vector && i == 1) + continue; + Operand op = instr->operands[i]; + is_subdword |= op.hasRegClass() && op.regClass().is_subdword(); + has_const_sgpr |= op.isConstant() || (op.hasRegClass() && op.regClass().type() == RegType::sgpr); + has_literal |= op.isLiteral(); + } - check(!is_subdword || !has_const_sgpr || program->chip_class >= GFX9, - "Sub-dword pseudo instructions can only take constants or SGPRs on GFX9+", instr.get()); - check(!is_subdword || !has_literal, "Sub-dword pseudo instructions cannot take literals", instr.get()); + check(!is_subdword || !has_const_sgpr || program->chip_class >= GFX9, + "Sub-dword pseudo instructions can only take constants or SGPRs on GFX9+", instr.get()); + check(!is_subdword || !has_literal, "Sub-dword pseudo instructions cannot take literals", instr.get()); + } if (instr->opcode == aco_opcode::p_create_vector) { unsigned size = 0; -- 2.7.4