[Mesa-dev] [PATCH 2/6] i965/fs: copy propagate 'NOT' instruction when used with logical operation
Abdiel Janulgue
abdiel.janulgue at linux.intel.com
Tue Jun 3 15:59:22 PDT 2014
On Broadwell, this reduces the instruction to 1 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 | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 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 d3d59aa..09d5949 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 {
@@ -341,6 +342,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;
}
@@ -480,9 +485,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 ||
@@ -548,10 +554,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.9.1
More information about the mesa-dev
mailing list