Mesa (master): i965/fs: Improve register coalescing interference check.

Matt Turner mattst88 at kemper.freedesktop.org
Fri Aug 28 18:27:04 UTC 2015


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

Author: Matt Turner <mattst88 at gmail.com>
Date:   Mon Aug 17 16:03:27 2015 -0700

i965/fs: Improve register coalescing interference check.

I always thought that the is_control_flow() -> return false check was a
bad hack, and some previous attempts to remove it have failed and have
been reverted.

The previous two patches fix some problems that caused register
coalescing to not notice some interference between registers, which the
is_control_flow() check apparently works around.

With that fixed, we can calculate interference more accurately.

total instructions in shared programs: 6261319 -> 6257917 (-0.05%)
instructions in affected programs:     346282 -> 342880 (-0.98%)
helped:                                1552

Reviewed-by: Jason Ekstrand <jason.ekstrand at intel.com>
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

---

 .../drivers/dri/i965/brw_fs_register_coalesce.cpp   |   19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs_register_coalesce.cpp b/src/mesa/drivers/dri/i965/brw_fs_register_coalesce.cpp
index 218cc61..452aee5 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_register_coalesce.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_register_coalesce.cpp
@@ -110,27 +110,30 @@ can_coalesce_vars(brw::fs_live_variables *live_intervals,
        (end_from > end_to && start_to < start_from))
       return false;
 
-   int start_ip = MIN2(start_to, start_from);
+   /* Check for a write to either register in the intersection of their live
+    * ranges.
+    */
+   int start_ip = MAX2(start_to, start_from);
+   int end_ip = MIN2(end_to, end_from);
    int scan_ip = -1;
 
    foreach_block_and_inst(block, fs_inst, scan_inst, cfg) {
       scan_ip++;
 
+      /* Ignore anything before the intersection of the live ranges */
       if (scan_ip < start_ip)
          continue;
 
-      if (scan_inst->is_control_flow())
-         return false;
-
-      if (scan_ip <= live_intervals->start[var_to])
+      /* Ignore the copying instruction itself */
+      if (scan_inst == inst)
          continue;
 
-      if (scan_ip > live_intervals->end[var_to])
-         return true;
+      if (scan_ip > end_ip)
+         return true; /* registers do not interfere */
 
       if (scan_inst->overwrites_reg(inst->dst) ||
           scan_inst->overwrites_reg(inst->src[0]))
-         return false;
+         return false; /* registers interfere */
    }
 
    return true;




More information about the mesa-commit mailing list