[Mesa-dev] [PATCH v2 5/6] i965/vec4: copy propagate 'NOT' instruction when used with logical operation

Abdiel Janulgue abdiel.janulgue at linux.intel.com
Thu Jun 5 11:05:32 PDT 2014


On Broadwell, this reduces the instruction to a single operation when NOT is used with
a logical instruction.

Signed-off-by: Abdiel Janulgue <abdiel.janulgue at linux.intel.com>
---
 .../drivers/dri/i965/brw_vec4_copy_propagation.cpp   | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp b/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp
index e537895..5eb4eb4 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp
@@ -42,9 +42,11 @@ struct copy_entry {
 };
 
 static bool
-is_direct_copy(vec4_instruction *inst)
+can_propagate_from(struct brw_context *brw, vec4_instruction *inst)
+
 {
-   return (inst->opcode == BRW_OPCODE_MOV &&
+   return ((inst->opcode == BRW_OPCODE_MOV ||
+            (inst->opcode == BRW_OPCODE_NOT && brw->gen >= 8)) &&
 	   !inst->predicate &&
 	   inst->dst.file == GRF &&
 	   !inst->saturate &&
@@ -248,7 +250,11 @@ vec4_visitor::try_copy_propagation(vec4_instruction *inst, int arg,
       return false;
 
    if (brw->gen >=8) {
-      if (value.negate) {
+      if (entry->opcode == BRW_OPCODE_NOT) {
+         if (!is_logic_op(inst->opcode)) {
+            return false;
+         }
+      } else if (value.negate) {
          if (is_logic_op(inst->opcode)) {
             return false;
          }
@@ -299,6 +305,10 @@ vec4_visitor::try_copy_propagation(vec4_instruction *inst, int arg,
 
    value.type = inst->src[arg].type;
    inst->src[arg] = value;
+
+   if (brw->gen >=8 && entry->opcode == BRW_OPCODE_NOT)
+      inst->src[arg].negate ^= !value.negate;
+
    return true;
 }
 
@@ -380,10 +390,10 @@ vec4_visitor::opt_copy_propagation()
 	  * the value is the newly propagated source.  Otherwise, we don't know
 	  * the new value, so clear it.
 	  */
-	 bool direct_copy = is_direct_copy(inst);
+	 bool propagate = can_propagate_from(brw, inst);
 	 for (int i = 0; i < 4; i++) {
 	    if (inst->dst.writemask & (1 << i)) {
-	       entries[reg].value[i] = direct_copy ? &inst->src[0] : NULL;
+	       entries[reg].value[i] = propagate ? &inst->src[0] : NULL;
 	       entries[reg].opcode = inst->opcode;
 	    }
 	 }
-- 
1.9.1



More information about the mesa-dev mailing list