diff --git a/src/amd/compiler/aco_spill.cpp b/src/amd/compiler/aco_spill.cpp index 93b7c975252..38e25dba3df 100644 --- a/src/amd/compiler/aco_spill.cpp +++ b/src/amd/compiler/aco_spill.cpp @@ -1186,6 +1186,15 @@ process_block(spill_ctx& ctx, unsigned block_idx, Block* block, RegisterDemand s while (idx < block->instructions.size()) { aco_ptr& instr = block->instructions[idx]; + /* Spilling is handled as part of phis (they should always have the same or higher register + * demand). If we try to spill here, we might not be able to reduce the register demand enough + * because there is no path to spill constant/undef phi operands. */ + if (instr->opcode == aco_opcode::p_branch) { + instructions.emplace_back(std::move(instr)); + idx++; + continue; + } + std::map> reloads; /* rename and reload operands */