diff --git a/.pick_status.json b/.pick_status.json index 81ec445a684..9b20f9d71db 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -391,7 +391,7 @@ "description": "aco/scheduler: Fix register demand computation for downwards moves", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "master_sha": null, "because_sha": "8235bc64112c701ae763c76417ad8bb0644ad8cb" }, diff --git a/src/amd/compiler/aco_scheduler.cpp b/src/amd/compiler/aco_scheduler.cpp index e3bce9a4b11..7be7e7057f9 100644 --- a/src/amd/compiler/aco_scheduler.cpp +++ b/src/amd/compiler/aco_scheduler.cpp @@ -115,7 +115,6 @@ void move_element(T begin_it, size_t idx, size_t before) { void MoveState::downwards_advance_helper() { source_idx--; - total_demand.update(register_demand[source_idx]); } void MoveState::downwards_init(int current_idx, bool improved_rar_, bool may_form_clauses) @@ -126,7 +125,8 @@ void MoveState::downwards_init(int current_idx, bool improved_rar_, bool may_for insert_idx = current_idx + 1; insert_idx_clause = current_idx; - total_demand = total_demand_clause = register_demand[current_idx]; + total_demand = register_demand[current_idx]; + total_demand_clause = {}; std::fill(depends_on.begin(), depends_on.end(), false); if (improved_rar) { @@ -194,11 +194,22 @@ MoveResult MoveState::downwards_move(bool clause) for (int i = source_idx; i < dest_insert_idx - 1; i++) register_demand[i] -= candidate_diff; register_demand[dest_insert_idx - 1] = new_demand; - total_demand_clause -= candidate_diff; insert_idx_clause--; + total_demand_clause -= candidate_diff; + if (source_idx == insert_idx_clause) { + total_demand_clause = RegisterDemand{}; + } if (!clause) { total_demand -= candidate_diff; insert_idx--; + } else { + /* The local demand of clause instructions did not change. But if + * previously total_demand_clause was greater than or equal to + * total_demand, the global maximum may have changed still */ + total_demand = total_demand_clause; + for (int i = insert_idx_clause; i < insert_idx; ++i) { + total_demand.update(register_demand[i]); + } } downwards_advance_helper(); @@ -219,6 +230,7 @@ void MoveState::downwards_skip() } } total_demand_clause.update(register_demand[source_idx]); + total_demand.update(register_demand[source_idx]); downwards_advance_helper(); }