i965/fs: Use the new per-channel live ranges for dead code elimination.
authorEric Anholt <eric@anholt.net>
Tue, 5 Jun 2012 18:42:25 +0000 (11:42 -0700)
committerEric Anholt <eric@anholt.net>
Thu, 10 Oct 2013 22:54:16 +0000 (15:54 -0700)
v2 (Kenneth Graunke): Rebase on s/live_variables/live_intervals/g.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/dri/i965/brw_fs.cpp
src/mesa/drivers/dri/i965/brw_fs_live_variables.h

index a046c3ca2c41e5e3f84887097dafa4c86f5dc4cc..74cc9cefb6db6a4d2b6c60ab307750df78514a99 100644 (file)
@@ -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;
          }
       }
 
index 694ad9edc69396b48f8690287edc2277e23e1a7c..fa14eecd89792eb0c13e608dee972397c483ddc8 100644 (file)
@@ -28,6 +28,8 @@
 #include "brw_fs.h"
 #include "main/bitset.h"
 
+class cfg_t;
+
 namespace brw {
 
 struct block_data {