From 1eb067ee9fc44ce9bdf603bd8eac3cf7ff1a582f Mon Sep 17 00:00:00 2001 From: Georg Lehmann Date: Wed, 28 Feb 2024 17:41:31 +0100 Subject: [PATCH] aco: store if pseudo instr needs scratch reg MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: mesa-stable Reviewed-by: Timur Kristóf Reviewed-by: Daniel Schürmann Part-of: --- src/amd/compiler/aco_ir.h | 2 +- src/amd/compiler/aco_register_allocation.cpp | 2 ++ src/amd/compiler/aco_ssa_elimination.cpp | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/amd/compiler/aco_ir.h b/src/amd/compiler/aco_ir.h index 184b4605da9..7d80ad03ae8 100644 --- a/src/amd/compiler/aco_ir.h +++ b/src/amd/compiler/aco_ir.h @@ -1633,7 +1633,7 @@ static_assert(sizeof(Export_instruction) == sizeof(Instruction) + 4, "Unexpected struct Pseudo_instruction : public Instruction { PhysReg scratch_sgpr; /* might not be valid if it's not needed */ bool tmp_in_scc; - uint8_t padding; + bool needs_scratch_reg; /* if scratch_sgpr/scc can be written, initialized by RA. */ }; static_assert(sizeof(Pseudo_instruction) == sizeof(Instruction) + 4, "Unexpected padding"); diff --git a/src/amd/compiler/aco_register_allocation.cpp b/src/amd/compiler/aco_register_allocation.cpp index 9c06c84674c..d5933b1bee7 100644 --- a/src/amd/compiler/aco_register_allocation.cpp +++ b/src/amd/compiler/aco_register_allocation.cpp @@ -1913,6 +1913,7 @@ handle_pseudo(ra_ctx& ctx, const RegisterFile& reg_file, Instruction* instr) if (!needs_scratch_reg) return; + instr->pseudo().needs_scratch_reg = true; instr->pseudo().tmp_in_scc = reg_file[scc]; int reg = ctx.max_used_sgpr; @@ -3067,6 +3068,7 @@ register_allocation(Program* program, std::vector& live_out_per_block, ra handle_pseudo(ctx, tmp_file, pc.get()); } else { + pc->needs_scratch_reg = sgpr_operands_alias_defs || linear_vgpr; pc->tmp_in_scc = false; } diff --git a/src/amd/compiler/aco_ssa_elimination.cpp b/src/amd/compiler/aco_ssa_elimination.cpp index 729449fcf7f..8229001168d 100644 --- a/src/amd/compiler/aco_ssa_elimination.cpp +++ b/src/amd/compiler/aco_ssa_elimination.cpp @@ -133,6 +133,7 @@ insert_parallelcopies(ssa_elimination_ctx& ctx) } pc->tmp_in_scc = block.scc_live_out; pc->scratch_sgpr = scratch_sgpr; + pc->needs_scratch_reg = true; block.instructions.insert(it, std::move(pc)); } }