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

2014-06-09 Thread Matt Turner
On Thu, Jun 5, 2014 at 11:05 AM, Abdiel Janulgue
abdiel.janul...@linux.intel.com wrote:
 On Broadwell, this reduces the instruction to a single operation when NOT is 
 used with
 a logical instruction.

 Signed-off-by: Abdiel Janulgue abdiel.janul...@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) {

Space between = and 8.

Also, there's a bit of code immediately before this:

   if (!inst-src[arg].abs) {
  inst-src[arg].abs = entry-src.abs;
  inst-src[arg].negate ^= entry-src.negate;
   }

I wonder how this might interfere? The Bspec explicitly describes how
abs and negate work before Broadwell, and how negate works after
Broadwell, but no mention of abs on Broadwell. I guess we'll need to
check.

 +  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)) 

Space between = and 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

 ___
 mesa-dev mailing list
 mesa-dev@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


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

2014-06-05 Thread Abdiel Janulgue
On Broadwell, this reduces the instruction to a single operation when NOT is 
used with
a logical instruction.

Signed-off-by: Abdiel Janulgue abdiel.janul...@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

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev