From 39413ef78f5dd17ff81949e1617fdde93053ca08 Mon Sep 17 00:00:00 2001 From: Natalie Vock Date: Mon, 24 Jun 2024 16:48:43 +0200 Subject: [PATCH] aco: Add get_temp_reg_changes helper Similar to get_live_changes, but considers live temporary registers as well. Part-of: --- src/amd/compiler/aco_ir.h | 1 + src/amd/compiler/aco_live_var_analysis.cpp | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/amd/compiler/aco_ir.h b/src/amd/compiler/aco_ir.h index 424c5fcab42..d78e4bc4084 100644 --- a/src/amd/compiler/aco_ir.h +++ b/src/amd/compiler/aco_ir.h @@ -2318,6 +2318,7 @@ int get_op_fixed_to_def(Instruction* instr); /* utilities for dealing with register demand */ RegisterDemand get_live_changes(Instruction* instr); RegisterDemand get_temp_registers(Instruction* instr); +RegisterDemand get_temp_reg_changes(Instruction* instr); /* adjust num_waves for workgroup size and LDS limits */ uint16_t max_suitable_waves(Program* program, uint16_t waves); diff --git a/src/amd/compiler/aco_live_var_analysis.cpp b/src/amd/compiler/aco_live_var_analysis.cpp index 4e7163ca141..94c431d59a9 100644 --- a/src/amd/compiler/aco_live_var_analysis.cpp +++ b/src/amd/compiler/aco_live_var_analysis.cpp @@ -55,6 +55,23 @@ get_temp_registers(Instruction* instr) return demand_after; } +RegisterDemand get_temp_reg_changes(Instruction* instr) +{ + RegisterDemand available_def_space; + + for (Definition def : instr->definitions) { + if (def.isTemp()) + available_def_space += def.getTemp(); + } + + for (Operand op : instr->operands) { + if (op.isFirstKillBeforeDef() || op.isCopyKill()) + available_def_space -= op.getTemp(); + } + + return available_def_space; +} + namespace { struct live_ctx {