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

Abdiel Janulgue abdiel.janulgue at linux.intel.com
Thu Jun 5 11:05:30 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>
---
 src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp b/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp
index aa506f5..54d2cb4 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp
@@ -341,7 +341,11 @@ fs_visitor::try_copy_propagate(fs_inst *inst, int arg, acp_entry *entry)
       return false;
 
    if (brw->gen >= 8) {
-      if (entry->src.negate) {
+      if (entry->opcode == BRW_OPCODE_NOT) {
+         if (!is_logic_op(inst->opcode)) {
+            return false;
+         }
+      } else if (entry->src.negate) {
          if (is_logic_op(inst->opcode)) {
             return false;
          }
@@ -359,6 +363,10 @@ fs_visitor::try_copy_propagate(fs_inst *inst, int arg, acp_entry *entry)
       inst->src[arg].negate ^= entry->src.negate;
    }
 
+   if (brw->gen >=8 && entry->opcode == BRW_OPCODE_NOT) {
+      inst->src[arg].negate ^= !entry->src.negate;
+   }
+
    return true;
 }
 
@@ -498,9 +506,10 @@ fs_visitor::try_constant_propagate(fs_inst *inst, acp_entry *entry)
 }
 
 static bool
-can_propagate_from(fs_inst *inst)
+can_propagate_from(struct brw_context *brw, fs_inst *inst)
 {
-   return (inst->opcode == BRW_OPCODE_MOV &&
+   return ((inst->opcode == BRW_OPCODE_MOV ||
+            (inst->opcode == BRW_OPCODE_NOT && brw->gen >=8)) &&
            inst->dst.file == GRF &&
            ((inst->src[0].file == GRF &&
              (inst->src[0].reg != inst->dst.reg ||
@@ -566,7 +575,7 @@ fs_visitor::opt_copy_propagate_local(void *copy_prop_ctx, bblock_t *block,
       /* If this instruction's source could potentially be folded into the
        * operand of another instruction, add it to the ACP.
        */
-      if (can_propagate_from(inst)) {
+      if (can_propagate_from(brw, inst)) {
 	 acp_entry *entry = ralloc(copy_prop_ctx, acp_entry);
 	 entry->dst = inst->dst;
 	 entry->src = inst->src[0];
-- 
1.9.1



More information about the mesa-dev mailing list