From 93872270f0f40c208a5241b4c1676c48b4c2b3dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Fri, 19 Apr 2024 11:43:00 +0200 Subject: [PATCH] aco/scheduler: keep track of RegisterDemand at DownwardsCursor::insert_idx{_clause} Part-of: --- src/amd/compiler/aco_scheduler.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/amd/compiler/aco_scheduler.cpp b/src/amd/compiler/aco_scheduler.cpp index 29a3cfdb1f1..97fb5329066 100644 --- a/src/amd/compiler/aco_scheduler.cpp +++ b/src/amd/compiler/aco_scheduler.cpp @@ -52,6 +52,10 @@ struct DownwardsCursor { RegisterDemand clause_demand; /* Maximum demand of instructions from source_idx to insert_idx_clause (both exclusive) */ RegisterDemand total_demand; + /* Register demand immediately before the insert_idx_clause. */ + RegisterDemand insert_demand_clause; + /* Register demand immediately before the insert_idx. */ + RegisterDemand insert_demand; DownwardsCursor(int current_idx, RegisterDemand initial_clause_demand) : source_idx(current_idx - 1), insert_idx_clause(current_idx), insert_idx(current_idx + 1), @@ -187,6 +191,12 @@ MoveState::downwards_init(int current_idx, bool improved_rar_, bool may_form_cla } DownwardsCursor cursor(current_idx, block->instructions[current_idx]->register_demand); + RegisterDemand temp = get_temp_registers(block->instructions[cursor.insert_idx - 1].get()); + cursor.insert_demand = block->instructions[cursor.insert_idx - 1]->register_demand - temp; + temp = get_temp_registers(block->instructions[cursor.insert_idx_clause - 1].get()); + cursor.insert_demand_clause = + block->instructions[cursor.insert_idx_clause - 1]->register_demand - temp; + cursor.verify_invariants(block); return cursor; } @@ -236,9 +246,9 @@ MoveState::downwards_move(DownwardsCursor& cursor, bool add_to_clause) /* New demand for the moved instruction */ const RegisterDemand temp = get_temp_registers(instr.get()); - const RegisterDemand temp2 = get_temp_registers(block->instructions[dest_insert_idx - 1].get()); - const RegisterDemand new_demand = - block->instructions[dest_insert_idx - 1]->register_demand - temp2 + temp; + const RegisterDemand insert_demand = + add_to_clause ? cursor.insert_demand_clause : cursor.insert_demand; + const RegisterDemand new_demand = insert_demand + temp; if (new_demand.exceeds(max_registers)) return move_fail_pressure; @@ -260,8 +270,10 @@ MoveState::downwards_move(DownwardsCursor& cursor, bool add_to_clause) cursor.clause_demand.update(new_demand); } else { cursor.clause_demand -= candidate_diff; + cursor.insert_demand -= candidate_diff; cursor.insert_idx--; } + cursor.insert_demand_clause -= candidate_diff; cursor.source_idx--; cursor.verify_invariants(block);