From: Abdiel Janulgue <abdiel.janul...@linux.intel.com> 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> --- v3 [mattst88]: Move bits not used by patch 2 into this. src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp | 19 +++++++++++++++---- 1 file changed, 15 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 158d0ba..d66f2e2 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp @@ -42,6 +42,7 @@ namespace { /* avoid conflict with opt_copy_propagation_elements */ struct acp_entry : public exec_node { fs_reg dst; fs_reg src; + enum opcode opcode; }; struct block_data { @@ -340,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; } @@ -358,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; } @@ -497,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 || @@ -565,10 +575,11 @@ 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]; + entry->opcode = inst->opcode; acp[entry->dst.reg % ACP_HASH_SIZE].push_tail(entry); } } -- 1.8.3.2 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev