[Mesa-dev] [PATCH 08/16] i965/fs: Don't search in vain for uses of dead channels.

Matt Turner mattst88 at gmail.com
Thu Dec 19 13:40:22 PST 2013


Improves three programs in Unigine Tropics.

total instructions in shared programs: 1549880 -> 1549868 (-0.00%)
instructions in affected programs:     858 -> 846 (-1.40%)
---
 src/mesa/drivers/dri/i965/brw_fs.cpp | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
index 39041e3..e4ac0a5 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -2270,10 +2270,15 @@ fs_visitor::register_coalesce()
    int reg_from = -1, reg_to = -1;
    int reg_to_offset[MAX_SAMPLER_MESSAGE_SIZE];
    fs_inst *mov[MAX_SAMPLER_MESSAGE_SIZE];
+   int last_use[MAX_SAMPLER_MESSAGE_SIZE];
+   int next_ip = 0;
 
    foreach_list_safe(node, &this->instructions) {
       fs_inst *inst = (fs_inst *)node;
 
+      int ip = next_ip;
+      next_ip++;
+
       if (inst->opcode != BRW_OPCODE_MOV ||
 	  inst->is_partial_write() ||
 	  inst->saturate ||
@@ -2306,6 +2311,14 @@ fs_visitor::register_coalesce()
          channels_remaining = src_size;
          memset(mov, 0, sizeof(mov));
 
+         fs_reg src = inst->src[0];
+         for (int i = 0; i < src_size; i++) {
+            src.reg_offset = i;
+            int var = live_intervals->var_from_reg(&src);
+
+            last_use[i] = live_intervals->end[var];
+         }
+
          reg_to = inst->dst.reg;
       }
 
@@ -2317,7 +2330,16 @@ fs_visitor::register_coalesce()
       mov[offset] = inst;
       channels_remaining--;
 
-      if (channels_remaining)
+      int live_channels_remaining = channels_remaining;
+      for (int i = 0; i < src_size; i++) {
+         if (!mov[i]) {
+            if (last_use[i] < ip) {
+               live_channels_remaining--;
+            }
+         }
+      }
+
+      if (live_channels_remaining)
          continue;
 
       for (int i = 0; i < src_size; i++) {
-- 
1.8.3.2



More information about the mesa-dev mailing list