Mesa (master): i965: Convert CMP.GE -(abs)reg 0 -> CMP.Z reg 0.

Matt Turner mattst88 at kemper.freedesktop.org
Sat Jan 24 01:56:21 UTC 2015


Module: Mesa
Branch: master
Commit: 94e7b59a75fc2ecc51a74196f6cd198546603b85
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=94e7b59a75fc2ecc51a74196f6cd198546603b85

Author: Matt Turner <mattst88 at gmail.com>
Date:   Mon Jan  5 13:51:03 2015 -0800

i965: Convert CMP.GE -(abs)reg 0 -> CMP.Z reg 0.

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 at whitecape.org>

---

 src/mesa/drivers/dri/i965/brw_fs.cpp   |   12 ++++++++++++
 src/mesa/drivers/dri/i965/brw_vec4.cpp |   12 ++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
index 7280b6b..0ada583 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -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;
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp b/src/mesa/drivers/dri/i965/brw_vec4.cpp
index 0fac949..8988196 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp
@@ -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) {




More information about the mesa-commit mailing list