i965: Don't dead-code eliminate instructions that write to the accumulator.
authorMatt Turner <mattst88@gmail.com>
Fri, 20 Sep 2013 02:31:31 +0000 (19:31 -0700)
committerMatt Turner <mattst88@gmail.com>
Mon, 7 Oct 2013 17:41:17 +0000 (10:41 -0700)
Reviewed-by: Paul Berry <stereotype441@gmail.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/dri/i965/brw_fs.cpp
src/mesa/drivers/dri/i965/brw_vec4.cpp

index b2c9f5a8e326ec986aa37975f5bea84603bf4153..b83aca447e58b6d7f35397656f526b261f85d97a 100644 (file)
@@ -1846,7 +1846,21 @@ fs_visitor::dead_code_eliminate()
       if (inst->dst.file == GRF) {
          assert(this->virtual_grf_end[inst->dst.reg] >= pc);
          if (this->virtual_grf_end[inst->dst.reg] == pc) {
-            inst->remove();
+            /* 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.file = ARF;
+               inst->dst.reg = BRW_ARF_NULL;
+               break;
+            default:
+               inst->remove();
+               break;
+            }
             progress = true;
          }
       }
index 75c3d344b5e5b782d3b1cab7b14fb6c3b9bf41be..790ff2ebc721518ad67df5ba8f9f83106277aa7a 100644 (file)
@@ -314,7 +314,21 @@ vec4_visitor::dead_code_eliminate()
       if (inst->dst.file == GRF) {
          assert(this->virtual_grf_end[inst->dst.reg] >= pc);
          if (this->virtual_grf_end[inst->dst.reg] == pc) {
-            inst->remove();
+            /* 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.file = ARF;
+               inst->dst.reg = BRW_ARF_NULL;
+               break;
+            default:
+               inst->remove();
+               break;
+            }
             progress = true;
          }
       }