Mesa (master): i965/vec4: Preparatory clean up of dead_code_eliminate().

Matt Turner mattst88 at kemper.freedesktop.org
Mon Mar 24 18:09:08 UTC 2014


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

Author: Matt Turner <mattst88 at gmail.com>
Date:   Tue Mar 11 13:04:26 2014 -0700

i965/vec4: Preparatory clean up of dead_code_eliminate().

Reviewed-by: Eric Anholt <eric at anholt.net>

---

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

diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp b/src/mesa/drivers/dri/i965/brw_vec4.cpp
index 62c2314..cb87fec 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp
@@ -322,7 +322,7 @@ src_reg::equals(src_reg *r)
 }
 
 /**
- * Must be called after calculate_live_intervales() to remove unused
+ * Must be called after calculate_live_intervals() to remove unused
  * writes to registers -- register allocation will fail otherwise
  * because something deffed but not used won't be considered to
  * interfere with other regs.
@@ -331,35 +331,36 @@ bool
 vec4_visitor::dead_code_eliminate()
 {
    bool progress = false;
-   int pc = 0;
+   int pc = -1;
 
    calculate_live_intervals();
 
    foreach_list_safe(node, &this->instructions) {
       vec4_instruction *inst = (vec4_instruction *)node;
 
-      if (inst->dst.file == GRF && !inst->has_side_effects()) {
-         assert(this->virtual_grf_end[inst->dst.reg] >= pc);
-         if (this->virtual_grf_end[inst->dst.reg] == pc) {
-            /* 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.
-             */
-            switch (inst->opcode) {
-            case BRW_OPCODE_ADDC:
-            case BRW_OPCODE_SUBB:
-            case BRW_OPCODE_MACH:
-               inst->dst = dst_reg(retype(brw_null_reg(), inst->dst.type));
-               break;
-            default:
-               inst->remove();
-               break;
-            }
-            progress = true;
+      pc++;
+
+      if (inst->dst.file != GRF || inst->has_side_effects())
+         continue;
+
+      assert(this->virtual_grf_end[inst->dst.reg] >= pc);
+      if (this->virtual_grf_end[inst->dst.reg] == pc) {
+         /* 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.
+          */
+         switch (inst->opcode) {
+         case BRW_OPCODE_ADDC:
+         case BRW_OPCODE_SUBB:
+         case BRW_OPCODE_MACH:
+            inst->dst = dst_reg(retype(brw_null_reg(), inst->dst.type));
+            break;
+         default:
+            inst->remove();
+            break;
          }
+         progress = true;
       }
-
-      pc++;
    }
 
    if (progress)




More information about the mesa-commit mailing list