[Mesa-dev] [PATCH] i965/fs: Relax interference check in register coalescing.

Matt Turner mattst88 at gmail.com
Wed Jul 9 12:41:57 PDT 2014


A similar attempt was made in commit 5ff1e446 and was reverted in commit
a39428cf after causing a regression in an ES 3 conformance test. The
test still passes after this commit.

total instructions in shared programs: 1994827 -> 1992858 (-0.10%)
instructions in affected programs:     128247 -> 126278 (-1.54%)
GAINED:                                0
LOST:                                  1
---
 .../drivers/dri/i965/brw_fs_register_coalesce.cpp  | 23 +++++++++++-----------
 1 file changed, 12 insertions(+), 11 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 e242e4f..3e3aeca 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_register_coalesce.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_register_coalesce.cpp
@@ -118,24 +118,25 @@ can_coalesce_vars(brw::fs_live_variables *live_intervals,
    if (!live_intervals->vars_interfere(var_from, var_to))
       return true;
 
-   /* We know that the live ranges of A (var_from) and B (var_to)
-    * interfere because of the ->vars_interfere() call above. If the end
-    * of B's live range is after the end of A's range, then we know two
-    * things:
-    *  - the start of B's live range must be in A's live range (since we
-    *    already know the two ranges interfere, this is the only remaining
-    *    possibility)
-    *  - the interference isn't of the form we're looking for (where B is
-    *    entirely inside A)
-    */
-   if (live_intervals->end[var_to] > live_intervals->end[var_from])
+   int start_to = live_intervals->start[var_to];
+   int end_to = live_intervals->end[var_to];
+   int start_from = live_intervals->start[var_from];
+   int end_from = live_intervals->end[var_from];
+
+   /* Variables interfere and one line range isn't a subset of the other. */
+   if ((end_to > end_from && start_from < start_to) ||
+       (end_from > end_to && start_to < start_from))
       return false;
 
+   int start_ip = MIN2(start_to, start_from);
    int scan_ip = -1;
 
    foreach_in_list(fs_inst, scan_inst, instructions) {
       scan_ip++;
 
+      if (scan_ip < start_ip)
+         continue;
+
       if (scan_inst->is_control_flow())
          return false;
 
-- 
1.8.5.5



More information about the mesa-dev mailing list