diff options
author | Matt Turner <[email protected]> | 2014-12-19 21:30:16 -0800 |
---|---|---|
committer | Matt Turner <[email protected]> | 2015-01-15 10:10:44 -0800 |
commit | c4fab711ed5bbdb6b8421a1b980215032fc795b8 (patch) | |
tree | a8674b7944ac51e25119a24e19b229ccdc99e443 /src/mesa | |
parent | 0d05d1226e0f51f703e0dcbf736375ee4f252473 (diff) |
i965/fs: Emit MADs from (x + -(y * z)).
Just use the negation source modifier on one of the multiplicand
arguments.
total instructions in shared programs: 5889529 -> 5880016 (-0.16%)
instructions in affected programs: 600846 -> 591333 (-1.58%)
Reviewed-by: Kristian Høgsberg <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp index 6ddb267cc19..7c062ec8abd 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp @@ -431,10 +431,21 @@ fs_visitor::try_emit_mad(ir_expression *ir) ir_rvalue *nonmul = ir->operands[1]; ir_expression *mul = ir->operands[0]->as_expression(); + bool mul_negate = false; + if (mul && mul->operation == ir_unop_neg) { + mul = mul->operands[0]->as_expression(); + mul_negate = true; + } + if (!mul || mul->operation != ir_binop_mul) { nonmul = ir->operands[0]; mul = ir->operands[1]->as_expression(); + if (mul && mul->operation == ir_unop_neg) { + mul = mul->operands[0]->as_expression(); + mul_negate = true; + } + if (!mul || mul->operation != ir_binop_mul) return false; } @@ -449,6 +460,7 @@ fs_visitor::try_emit_mad(ir_expression *ir) mul->operands[0]->accept(this); fs_reg src1 = this->result; + src1.negate ^= mul_negate; mul->operands[1]->accept(this); fs_reg src2 = this->result; |