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)); } }