i965/fs: Optimize SEL with the same sources into a MOV.
authorMatt Turner <mattst88@gmail.com>
Fri, 18 Apr 2014 17:01:41 +0000 (10:01 -0700)
committerMatt Turner <mattst88@gmail.com>
Tue, 17 Jun 2014 16:40:31 +0000 (09:40 -0700)
instructions in affected programs:     474 -> 462 (-2.53%)

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/dri/i965/brw_fs.cpp

index 62868d112459a0bf8ea01ed3cdc774f06cc91714..d7b969e46c58d05a995a3cf5f5b66e9bc556c790 100644 (file)
@@ -2021,7 +2021,13 @@ fs_visitor::opt_algebraic()
          }
          break;
       case BRW_OPCODE_SEL:
-         if (inst->saturate && inst->src[1].file == IMM) {
+         if (inst->src[0].equals(inst->src[1])) {
+            inst->opcode = BRW_OPCODE_MOV;
+            inst->src[1] = reg_undef;
+            inst->predicate = BRW_PREDICATE_NONE;
+            inst->predicate_inverse = false;
+            progress = true;
+         } else if (inst->saturate && inst->src[1].file == IMM) {
             switch (inst->conditional_mod) {
             case BRW_CONDITIONAL_LE:
             case BRW_CONDITIONAL_L: