Mesa (master): i965: Eliminate dead code more aggressively.

Eric Anholt anholt at kemper.freedesktop.org
Thu Nov 18 03:17:44 UTC 2010


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

Author: Eric Anholt <eric at anholt.net>
Date:   Thu Nov 18 10:44:34 2010 +0800

i965: Eliminate dead code more aggressively.

If an instruction writes reg but nothing later uses it, then we don't
need to bother doing it.  Before, we were just killing code that was
never read after it was ever written.

This removes many interpolation instructions for attributes with only
a few comopnents used.  Improves nexuiz high-settings performance .46%
+/- .12% (n=3) on my Ironlake.

---

 src/mesa/drivers/dri/i965/brw_fs.cpp |   17 ++++-------------
 1 files changed, 4 insertions(+), 13 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
index b12a480..ac795e0 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -2801,26 +2801,17 @@ bool
 fs_visitor::dead_code_eliminate()
 {
    bool progress = false;
-   int num_vars = this->virtual_grf_next;
-   bool dead[num_vars];
-
-   for (int i = 0; i < num_vars; i++) {
-      dead[i] = this->virtual_grf_def[i] >= this->virtual_grf_use[i];
-
-      if (dead[i]) {
-	 /* Mark off its interval so it won't interfere with anything. */
-	 this->virtual_grf_def[i] = -1;
-	 this->virtual_grf_use[i] = -1;
-      }
-   }
+   int pc = 0;
 
    foreach_iter(exec_list_iterator, iter, this->instructions) {
       fs_inst *inst = (fs_inst *)iter.get();
 
-      if (inst->dst.file == GRF && dead[inst->dst.reg]) {
+      if (inst->dst.file == GRF && this->virtual_grf_use[inst->dst.reg] <= pc) {
 	 inst->remove();
 	 progress = true;
       }
+
+      pc++;
    }
 
    return progress;




More information about the mesa-commit mailing list