From 8d6246205ad3d71efd644e1d1b60827aa6e54298 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timur=20Krist=C3=B3f?= Date: Thu, 15 Oct 2020 10:23:42 +0200 Subject: [PATCH] aco: Add some validation for PSEUDO_REDUCTION instructions. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Timur Kristóf Reviewed-by: Rhys Perry Part-of: --- src/amd/compiler/aco_validate.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/amd/compiler/aco_validate.cpp b/src/amd/compiler/aco_validate.cpp index 87a48d8ad70..b1c46143b4d 100644 --- a/src/amd/compiler/aco_validate.cpp +++ b/src/amd/compiler/aco_validate.cpp @@ -401,6 +401,19 @@ bool validate_ir(Program* program) } break; } + case Format::PSEUDO_REDUCTION: { + for (const Operand &op : instr->operands) + check(op.regClass().type() == RegType::vgpr, "All operands of PSEUDO_REDUCTION instructions must be in VGPRs.", instr.get()); + + unsigned cluster_size = static_cast(instr.get())->cluster_size; + + if (instr->opcode == aco_opcode::p_reduce && cluster_size == program->wave_size) + check(instr->definitions[0].regClass().type() == RegType::sgpr, "The result of unclustered reductions must go into an SGPR.", instr.get()); + else + check(instr->definitions[0].regClass().type() == RegType::vgpr, "The result of scans and clustered reductions must go into a VGPR.", instr.get()); + + break; + } case Format::SMEM: { if (instr->operands.size() >= 1) check((instr->operands[0].isFixed() && !instr->operands[0].isConstant()) ||