aco: fix new_demand calculation for first instructions
authorRhys Perry <pendingchaos02@gmail.com>
Wed, 30 Oct 2019 18:00:36 +0000 (18:00 +0000)
committerDaniel Schürmann <daniel@schuermann.dev>
Wed, 30 Oct 2019 19:48:33 +0000 (19:48 +0000)
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
src/amd/compiler/aco_spill.cpp

index 6959895d858c211d9f6065b5f44598aeb80202c2..60a99aa92473c01d63d5d4b4dff0a5415e2a4c62 100644 (file)
@@ -1033,11 +1033,14 @@ void process_block(spill_ctx& ctx, unsigned block_idx, Block* block,
 
          RegisterDemand new_demand = ctx.register_demand[block_idx][idx];
          if (idx == 0) {
-            for (const Definition& def : instr->definitions) {
-               if (!def.isTemp())
-                  continue;
-               new_demand += def.getTemp();
+            RegisterDemand demand_before = new_demand;
+            for (const Definition& def : instr->definitions)
+               demand_before -= def.getTemp();
+            for (const Operand& op : instr->operands) {
+               if (op.isFirstKill())
+                  demand_before += op.getTemp();
             }
+            new_demand.update(demand_before);
          } else {
             new_demand.update(ctx.register_demand[block_idx][idx - 1]);
          }