i965/fs: Decide predicate/predicate_inverse outside of the for loop.
authorMatt Turner <mattst88@gmail.com>
Tue, 11 Feb 2014 21:12:07 +0000 (13:12 -0800)
committerMatt Turner <mattst88@gmail.com>
Thu, 24 Jul 2014 18:27:44 +0000 (11:27 -0700)
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/dri/i965/brw_fs_sel_peephole.cpp

index c0bba8e7ced553f18332b9bba0ea43d323683caa..03c7ee64538832cef212464fc3e9d8a27552fefe 100644 (file)
@@ -156,6 +156,18 @@ fs_visitor::opt_peephole_sel()
       fs_inst *sel_inst[MAX_MOVS] = { NULL };
       fs_inst *mov_imm_inst[MAX_MOVS] = { NULL };
 
+      enum brw_predicate predicate;
+      bool predicate_inverse;
+      if (brw->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])
@@ -190,15 +202,8 @@ fs_visitor::opt_peephole_sel()
             }
 
             sel_inst[i] = SEL(then_mov[i]->dst, src0, else_mov[i]->src[0]);
-
-            if (brw->gen == 6 && if_inst->conditional_mod) {
-               /* For Sandybridge with IF with embedded comparison */
-               sel_inst[i]->predicate = BRW_PREDICATE_NORMAL;
-            } else {
-               /* Separate CMP and IF instructions */
-               sel_inst[i]->predicate = if_inst->predicate;
-               sel_inst[i]->predicate_inverse = if_inst->predicate_inverse;
-            }
+            sel_inst[i]->predicate = predicate;
+            sel_inst[i]->predicate_inverse = predicate_inverse;
          }
       }