Mesa (master): i965: Combine some dead code elimination NOP'ing code.

Kenneth Graunke kwg at kemper.freedesktop.org
Wed Jan 18 05:45:39 UTC 2017


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

Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Wed Dec 14 17:56:35 2016 -0800

i965: Combine some dead code elimination NOP'ing code.

In theory we might have incorrectly NOP'd instructions that write the
flag, but where that flag value isn't used, and yet the instruction
either writes the accumulator or has side effects.

I don't believe any such instructions exist, so this is mostly a
code cleanup.

Curro pointed out that FS_OPCODE_FB_WRITE has a null destination and
actually writes the flag on Gen4-5 to dynamically decide whether to
write some payload data.  The hunk removed in this patch might have
NOP'd it, except that we don't actually mark flags_written() in the
IR, so it doesn't think the flag is touched at all.  That's sketchy,
but it means it wouldn't hit this today (though there are likely other
problems!).

v2: Properly replace the inst->regs_written() check in the second
    hunk with the flag being live (mistake caught by Curro).

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
Reviewed-by: Francisco Jerez <currojerez at riseup.net>
Reviewed-by: Matt Turner <mattst88 at gmail.com>

---

 src/mesa/drivers/dri/i965/brw_fs_dead_code_eliminate.cpp | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs_dead_code_eliminate.cpp b/src/mesa/drivers/dri/i965/brw_fs_dead_code_eliminate.cpp
index 04901a9..0dd6091 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_dead_code_eliminate.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_dead_code_eliminate.cpp
@@ -70,17 +70,10 @@ fs_visitor::dead_code_eliminate()
             }
          }
 
-         if (inst->dst.is_null() && inst->flags_written()) {
-            if (!(flag_live[0] & inst->flags_written())) {
-               inst->opcode = BRW_OPCODE_NOP;
-               progress = true;
-            }
-         }
-
          if (inst->dst.is_null() &&
              !inst->is_control_flow() &&
              !inst->has_side_effects() &&
-             !inst->flags_written() &&
+             !(flag_live[0] & inst->flags_written()) &&
              !inst->writes_accumulator) {
             inst->opcode = BRW_OPCODE_NOP;
             progress = true;




More information about the mesa-commit mailing list