Mesa (master): intel/fs: Skip registers faster when setting spill costs

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jun 4 15:02:36 UTC 2019


Module: Mesa
Branch: master
Commit: a84de3fb7c1198f7cbd3b20a4231c14a7010f97f
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a84de3fb7c1198f7cbd3b20a4231c14a7010f97f

Author: Jason Ekstrand <jason at jlekstrand.net>
Date:   Mon Jun  3 17:09:12 2019 -0500

intel/fs: Skip registers faster when setting spill costs

This might be slightly faster since we're doing one read rather than
two before we decide to skip.  The more important reason, however, is
because no_spill prevents us from re-spilling spill registers.  In the
new world in which we don't re-calculate liveness every spill, we may
not have valid liveness for spill registers so we shouldn't even look
their live ranges up.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=110825
Fixes: e99081e76d4 "intel/fs/ra: Spill without destroying the..."
Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira at intel.com>
Tested-by: Tapani Pälli <tapani.palli at intel.com>

---

 src/intel/compiler/brw_fs_reg_allocate.cpp | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/intel/compiler/brw_fs_reg_allocate.cpp b/src/intel/compiler/brw_fs_reg_allocate.cpp
index 33631ddcd0c..6a594a4f520 100644
--- a/src/intel/compiler/brw_fs_reg_allocate.cpp
+++ b/src/intel/compiler/brw_fs_reg_allocate.cpp
@@ -922,6 +922,15 @@ fs_reg_alloc::set_spill_costs()
    }
 
    for (unsigned i = 0; i < fs->alloc.count; i++) {
+      /* Do the no_spill check first.  Registers that are used as spill
+       * temporaries may have been allocated after we calculated liveness so
+       * we shouldn't look their liveness up.  Fortunately, they're always
+       * used in SCRATCH_READ/WRITE instructions so they'll always be flagged
+       * no_spill.
+       */
+      if (no_spill[i])
+         continue;
+
       int live_length = fs->virtual_grf_end[i] - fs->virtual_grf_start[i];
       if (live_length <= 0)
          continue;
@@ -934,8 +943,7 @@ fs_reg_alloc::set_spill_costs()
        * to spill medium length registers with more uses.
        */
       float adjusted_cost = spill_costs[i] / logf(live_length);
-      if (!no_spill[i])
-	 ra_set_node_spill_cost(g, first_vgrf_node + i, adjusted_cost);
+      ra_set_node_spill_cost(g, first_vgrf_node + i, adjusted_cost);
    }
 
    have_spill_costs = true;




More information about the mesa-commit mailing list