Mesa (master): i965/fs: Use the new per-channel live ranges for dead code elimination.

Eric Anholt anholt at kemper.freedesktop.org
Thu Oct 10 23:30:15 UTC 2013


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

Author: Eric Anholt <eric at anholt.net>
Date:   Tue Jun  5 11:42:25 2012 -0700

i965/fs: Use the new per-channel live ranges for dead code elimination.

v2 (Kenneth Graunke): Rebase on s/live_variables/live_intervals/g.

Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

---

 src/mesa/drivers/dri/i965/brw_fs.cpp              |   17 ++++++++++++++---
 src/mesa/drivers/dri/i965/brw_fs_live_variables.h |    2 ++
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
index a046c3c..74cc9ce 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -47,6 +47,7 @@ extern "C" {
 }
 #include "brw_fs.h"
 #include "main/uniforms.h"
+#include "brw_fs_live_variables.h"
 #include "glsl/glsl_types.h"
 
 void
@@ -1841,8 +1842,18 @@ fs_visitor::dead_code_eliminate()
       fs_inst *inst = (fs_inst *)node;
 
       if (inst->dst.file == GRF) {
-         assert(this->virtual_grf_end[inst->dst.reg] >= pc);
-         if (this->virtual_grf_end[inst->dst.reg] == pc) {
+         bool dead = true;
+
+         for (int i = 0; i < inst->regs_written; i++) {
+            int var = live_intervals->var_from_vgrf[inst->dst.reg];
+            assert(live_intervals->end[var + inst->dst.reg_offset + i] >= pc);
+            if (live_intervals->end[var + inst->dst.reg_offset + i] != pc) {
+               dead = false;
+               break;
+            }
+         }
+
+         if (dead) {
             /* Don't dead code eliminate instructions that write to the
              * accumulator as a side-effect. Instead just set the destination
              * to the null register to free it.
@@ -1855,9 +1866,9 @@ fs_visitor::dead_code_eliminate()
                break;
             default:
                inst->remove();
+               progress = true;
                break;
             }
-            progress = true;
          }
       }
 
diff --git a/src/mesa/drivers/dri/i965/brw_fs_live_variables.h b/src/mesa/drivers/dri/i965/brw_fs_live_variables.h
index 694ad9e..fa14eec 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_live_variables.h
+++ b/src/mesa/drivers/dri/i965/brw_fs_live_variables.h
@@ -28,6 +28,8 @@
 #include "brw_fs.h"
 #include "main/bitset.h"
 
+class cfg_t;
+
 namespace brw {
 
 struct block_data {




More information about the mesa-commit mailing list