[Mesa-dev] [PATCH 1/3] i965/fs: Remove SNB embedded-comparison support from optimizations.

Matt Turner mattst88 at gmail.com
Sat Oct 3 10:58:03 PDT 2015


We never emit IF instructions with an embedded comparison (lost in the
switch to NIR), so this code is not used. If we want to readd support,
we should have a pass that merges a CMP instruction with an IF or a
WHILE instruction after other optimizations have run.
---
 .../dri/i965/brw_fs_peephole_predicated_break.cpp   | 14 ++------------
 src/mesa/drivers/dri/i965/brw_fs_sel_peephole.cpp   | 21 +--------------------
 2 files changed, 3 insertions(+), 32 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs_peephole_predicated_break.cpp b/src/mesa/drivers/dri/i965/brw_fs_peephole_predicated_break.cpp
index b75f40b..8f7bd83 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_peephole_predicated_break.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_peephole_predicated_break.cpp
@@ -83,18 +83,8 @@ fs_visitor::opt_peephole_predicated_break()
       bblock_t *if_block = jump_block->prev();
       bblock_t *endif_block = jump_block->next();
 
-      /* For Sandybridge with IF with embedded comparison we need to emit an
-       * instruction to set the flag register.
-       */
-      if (devinfo->gen == 6 && if_inst->conditional_mod) {
-         const fs_builder ibld(this, if_block, if_inst);
-         ibld.CMP(ibld.null_reg_d(), if_inst->src[0], if_inst->src[1],
-                  if_inst->conditional_mod);
-         jump_inst->predicate = BRW_PREDICATE_NORMAL;
-      } else {
-         jump_inst->predicate = if_inst->predicate;
-         jump_inst->predicate_inverse = if_inst->predicate_inverse;
-      }
+      jump_inst->predicate = if_inst->predicate;
+      jump_inst->predicate_inverse = if_inst->predicate_inverse;
 
       bblock_t *earlier_block = if_block;
       if (if_block->start_ip == if_block->end_ip) {
diff --git a/src/mesa/drivers/dri/i965/brw_fs_sel_peephole.cpp b/src/mesa/drivers/dri/i965/brw_fs_sel_peephole.cpp
index d190d8e..8613725 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_sel_peephole.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_sel_peephole.cpp
@@ -155,18 +155,6 @@ fs_visitor::opt_peephole_sel()
       if (movs == 0)
          continue;
 
-      enum brw_predicate predicate;
-      bool predicate_inverse;
-      if (devinfo->gen == 6 && if_inst->conditional_mod) {
-         /* For Sandybridge with IF with embedded comparison */
-         predicate = BRW_PREDICATE_NORMAL;
-         predicate_inverse = false;
-      } else {
-         /* Separate CMP and IF instructions */
-         predicate = if_inst->predicate;
-         predicate_inverse = if_inst->predicate_inverse;
-      }
-
       /* Generate SEL instructions for pairs of MOVs to a common destination. */
       for (int i = 0; i < movs; i++) {
          if (!then_mov[i] || !else_mov[i])
@@ -195,13 +183,6 @@ fs_visitor::opt_peephole_sel()
       if (movs == 0)
          continue;
 
-      /* Emit a CMP if our IF used the embedded comparison */
-      if (devinfo->gen == 6 && if_inst->conditional_mod) {
-         const fs_builder ibld(this, block, if_inst);
-         ibld.CMP(ibld.null_reg_d(), if_inst->src[0], if_inst->src[1],
-                  if_inst->conditional_mod);
-      }
-
       for (int i = 0; i < movs; i++) {
          const fs_builder ibld = fs_builder(this, then_block, then_mov[i])
                                  .at(block, if_inst);
@@ -220,7 +201,7 @@ fs_visitor::opt_peephole_sel()
                ibld.MOV(src0, then_mov[i]->src[0]);
             }
 
-            set_predicate_inv(predicate, predicate_inverse,
+            set_predicate_inv(if_inst->predicate, if_inst->predicate_inverse,
                               ibld.SEL(then_mov[i]->dst, src0,
                                        else_mov[i]->src[0]));
          }
-- 
2.4.9



More information about the mesa-dev mailing list