Mesa (master): i965/vec4: Let DCE eliminate dead writes in other basic blocks.

Matt Turner mattst88 at kemper.freedesktop.org
Tue Apr 15 17:24:39 UTC 2014


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

Author: Matt Turner <mattst88 at gmail.com>
Date:   Mon Mar 24 13:23:13 2014 -0700

i965/vec4: Let DCE eliminate dead writes in other basic blocks.

We previously stopped searching for unread writes after encountering
control flow, but we can instead just search backwards until we hit
control flow.

instructions in affected programs:     22854 -> 22194 (-2.89%)

---

 src/mesa/drivers/dri/i965/brw_vec4.cpp |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp b/src/mesa/drivers/dri/i965/brw_vec4.cpp
index 740d9ff..c34eec4 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp
@@ -378,7 +378,6 @@ bool
 vec4_visitor::dead_code_eliminate()
 {
    bool progress = false;
-   bool seen_control_flow = false;
    int pc = -1;
 
    calculate_live_intervals();
@@ -388,8 +387,6 @@ vec4_visitor::dead_code_eliminate()
 
       pc++;
 
-      seen_control_flow = inst->is_control_flow() || seen_control_flow;
-
       bool inst_writes_flag = false;
       if (inst->dst.file != GRF) {
          if (inst->dst.is_null() && inst->writes_flag()) {
@@ -415,7 +412,7 @@ vec4_visitor::dead_code_eliminate()
                     progress;
       }
 
-      if (seen_control_flow || inst->predicate || inst->prev == NULL)
+      if (inst->predicate || inst->prev == NULL)
          continue;
 
       int dead_channels;
@@ -443,6 +440,9 @@ vec4_visitor::dead_code_eliminate()
            node = prev, prev = prev->prev) {
          vec4_instruction *scan_inst = (vec4_instruction  *)node;
 
+         if (scan_inst->is_control_flow())
+            break;
+
          if (inst_writes_flag) {
             if (scan_inst->dst.is_null() && scan_inst->writes_flag()) {
                scan_inst->remove();




More information about the mesa-commit mailing list