i965/vec4: Perform CSE on MAD instructions with final arguments switched.
authorMatt Turner <mattst88@gmail.com>
Sun, 26 Oct 2014 17:31:21 +0000 (10:31 -0700)
committerMatt Turner <mattst88@gmail.com>
Thu, 30 Oct 2014 04:35:46 +0000 (21:35 -0700)
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/dri/i965/brw_vec4_cse.cpp

index 28c69ca69d1b46ea0ed80dbdbd9d4db5bbe1d2e1..630d3357a3ff01a4865c9813db39c3392de73926 100644 (file)
@@ -104,7 +104,11 @@ is_expression_commutative(enum opcode op)
 static bool
 operands_match(enum opcode op, src_reg *xs, src_reg *ys)
 {
-   if (!is_expression_commutative(op)) {
+   if (op == BRW_OPCODE_MAD) {
+      return xs[0].equals(ys[0]) &&
+             ((xs[1].equals(ys[1]) && xs[2].equals(ys[2])) ||
+              (xs[2].equals(ys[1]) && xs[1].equals(ys[2])));
+   } else 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])) ||