i965/vec4: Don't unspill the same register in consecutive instructions
authorIago Toral Quiroga <itoral@igalia.com>
Fri, 4 Sep 2015 11:23:20 +0000 (13:23 +0200)
committerIago Toral Quiroga <itoral@igalia.com>
Fri, 4 Sep 2015 13:13:49 +0000 (15:13 +0200)
commit96ea1663082c4a17eaf59873190f1e9677623d91
treefc147cca6f5dd5507b84a210afbf086e4e1d4df0
parentbd6e516fc24128d604f677a16f692d88d65a49f1
i965/vec4: Don't unspill the same register in consecutive instructions

If we have spilled/unspilled a register in the current instruction, avoid
emitting unspills for the same register in the same instruction or consecutive
instructions following the current one as long as they keep reading the spilled
register. This should allow us to avoid emitting costy unspills that come with
little benefit to register allocation.

v2:
  - Apply the same logic when evaluating spilling costs (Curro).

v3:
  - Abstract the logic that decides if a register can be reused in a function.
    that can be used from both spill_reg and evaluate_spill_costs (Curro).

v4:
  - Do not disallow reusing scratch_reg in predicated reads (Curro).
  - Track if previous sources in the same instruction read scratch_reg (Curro).
  - Return prev_inst_read_scratch_reg at the end (Curro).
  - No need to explicitily skip scratch read/write opcodes in spill_reg (Curro).
  - Fix the comments explaining what happens when we hit an instruction that
    does not read or write scratch_reg (Curro)
  - Return true early when the current or previous instructions read
    scratch_reg with a compatible mask.

v5:
  - Do not return true early, the loop should not be expensive anyway
    and this adds more complexity (Curro).

Reviewed-by: Francisco Jerez <currojerez@riseup.net>
src/mesa/drivers/dri/i965/brw_vec4_reg_allocate.cpp