aco: fix underestimated pressure in spiller when a phi has a killed def
authorRhys Perry <pendingchaos02@gmail.com>
Tue, 7 Jul 2020 17:16:47 +0000 (18:16 +0100)
committerMarge Bot <eric+marge@anholt.net>
Thu, 16 Jul 2020 16:22:57 +0000 (16:22 +0000)
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5805>

src/amd/compiler/aco_spill.cpp

index 62ab69a045be7cf8f9106d1b36151250a6a9a77f..7db3248e20f6430709035e3ead83b55f10e64f71 100644 (file)
@@ -604,6 +604,17 @@ RegisterDemand init_live_in_vars(spill_ctx& ctx, Block* block, unsigned block_id
          }
       }
    } else {
+      for (unsigned i = 0; i < idx; i++) {
+         aco_ptr<Instruction>& instr = block->instructions[i];
+         assert(is_phi(instr));
+         /* Killed phi definitions increase pressure in the predecessor but not
+          * the block they're in. Since the loops below are both to control
+          * pressure of the start of this block and the ends of it's
+          * predecessors, we need to count killed unspilled phi definitions here. */
+         if (instr->definitions[0].isKill() &&
+             !ctx.spills_entry[block_idx].count(instr->definitions[0].getTemp()))
+            reg_pressure += instr->definitions[0].getTemp();
+      }
       idx--;
    }
    reg_pressure += ctx.register_demand[block_idx][idx] - spilled_registers;