summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri/i965/brw_fs_cse.cpp
diff options
context:
space:
mode:
authorMatt Turner <mattst88@gmail.com>2013-10-18 16:02:11 -0700
committerMatt Turner <mattst88@gmail.com>2013-10-25 10:34:02 -0700
commite52959e9612e6e645407c6256d35fac9c8fe3276 (patch)
tree50dd247452c6069ddb4bfc028b878be22eb079ee /src/mesa/drivers/dri/i965/brw_fs_cse.cpp
parent503fe278b070285b75a4000408873973d8d5f2b1 (diff)
i965/fs: Match commutative expressions with reversed arguments.
total instructions in shared programs: 1645011 -> 1644938 (-0.00%) instructions in affected programs: 17543 -> 17470 (-0.42%) Reviewed-by: Eric Anholt <eric@anholt.net>
Diffstat (limited to 'src/mesa/drivers/dri/i965/brw_fs_cse.cpp')
-rw-r--r--src/mesa/drivers/dri/i965/brw_fs_cse.cpp26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_fs_cse.cpp b/src/mesa/drivers/dri/i965/brw_fs_cse.cpp
index ab3e561724..0afc5f65f6 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_cse.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_cse.cpp
@@ -77,9 +77,29 @@ is_expression(const fs_inst *const inst)
}
static bool
-operands_match(fs_reg *xs, fs_reg *ys)
+is_expression_commutative(enum opcode op)
{
- return xs[0].equals(ys[0]) && xs[1].equals(ys[1]) && xs[2].equals(ys[2]);
+ switch (op) {
+ case BRW_OPCODE_AND:
+ case BRW_OPCODE_OR:
+ case BRW_OPCODE_XOR:
+ case BRW_OPCODE_ADD:
+ case BRW_OPCODE_MUL:
+ return true;
+ default:
+ return false;
+ }
+}
+
+static bool
+operands_match(enum opcode op, fs_reg *xs, fs_reg *ys)
+{
+ if (!is_expression_commutative(op)) {
+ return xs[0].equals(ys[0]) && xs[1].equals(ys[1]) && xs[2].equals(ys[2]);
+ } else {
+ return (xs[0].equals(ys[0]) && xs[1].equals(ys[1])) ||
+ (xs[1].equals(ys[0]) && xs[0].equals(ys[1]));
+ }
}
bool
@@ -111,7 +131,7 @@ fs_visitor::opt_cse_local(bblock_t *block, exec_list *aeb)
if (inst->opcode == entry->generator->opcode &&
inst->saturate == entry->generator->saturate &&
inst->dst.type == entry->generator->dst.type &&
- operands_match(entry->generator->src, inst->src)) {
+ operands_match(inst->opcode, entry->generator->src, inst->src)) {
found = true;
progress = true;