i965: Convert CMP.GE -(abs)reg 0 -> CMP.Z reg 0.
authorMatt Turner <mattst88@gmail.com>
Mon, 5 Jan 2015 21:51:03 +0000 (13:51 -0800)
committerMatt Turner <mattst88@gmail.com>
Sat, 24 Jan 2015 01:57:40 +0000 (17:57 -0800)
total instructions in shared programs: 5952059 -> 5951603 (-0.01%)
instructions in affected programs:     138812 -> 138356 (-0.33%)
GAINED:                                1
LOST:                                  0

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

index 7280b6bac2613958f9dc5674bd7bdc81c7c92c03..0ada5837cfd082d111de1bc8a6ac627894b0501a 100644 (file)
@@ -2367,6 +2367,18 @@ fs_visitor::opt_algebraic()
             break;
          }
          break;
+      case BRW_OPCODE_CMP:
+         if (inst->conditional_mod == BRW_CONDITIONAL_GE &&
+             inst->src[0].abs &&
+             inst->src[0].negate &&
+             inst->src[1].is_zero()) {
+            inst->src[0].abs = false;
+            inst->src[0].negate = false;
+            inst->conditional_mod = BRW_CONDITIONAL_Z;
+            progress = true;
+            break;
+         }
+         break;
       case BRW_OPCODE_SEL:
          if (inst->src[0].equals(inst->src[1])) {
             inst->opcode = BRW_OPCODE_MOV;
index 0fac949521058f71695629608360ee644819fe31..89881967dfd2214f21ac65fb01dd69e837894df0 100644 (file)
@@ -693,6 +693,18 @@ vec4_visitor::opt_algebraic()
            progress = true;
         }
         break;
+      case BRW_OPCODE_CMP:
+         if (inst->conditional_mod == BRW_CONDITIONAL_GE &&
+             inst->src[0].abs &&
+             inst->src[0].negate &&
+             inst->src[1].is_zero()) {
+            inst->src[0].abs = false;
+            inst->src[0].negate = false;
+            inst->conditional_mod = BRW_CONDITIONAL_Z;
+            progress = true;
+            break;
+         }
+         break;
       case SHADER_OPCODE_RCP: {
          vec4_instruction *prev = (vec4_instruction *)inst->prev;
          if (prev->opcode == SHADER_OPCODE_SQRT) {