[Mesa-dev] [PATCH 05/15] i965/fs: Don't dead code eliminate CMP(N).

Matt Turner mattst88 at gmail.com
Mon Oct 28 19:31:29 CET 2013


Since compare instructions write the flag register, they should not be
considered dead even if their destination is never read. Instead of
removing them if found to be dead, set their destination to null to free
a register.
---
 src/mesa/drivers/dri/i965/brw_fs.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
index 7e7ced0..b985251 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -1903,10 +1903,12 @@ fs_visitor::dead_code_eliminate()
 
          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.
+             * accumulator or flag register as a side effect. Instead just set
+             * the destination to the null register to free it.
              */
             switch (inst->opcode) {
+            case BRW_OPCODE_CMP:
+            case BRW_OPCODE_CMPN:
             case BRW_OPCODE_ADDC:
             case BRW_OPCODE_SUBB:
             case BRW_OPCODE_MACH:
-- 
1.8.3.2



More information about the mesa-dev mailing list