On Tue, Jan 13, 2015 at 3:00 PM, Matt Turner <matts...@gmail.com> wrote: > Just use the abs source modifier on both of the multiplicand > arguments. > > instructions in affected programs: 300 -> 296 (-1.33%)
Reviewed-by: Kristian Høgsberg <k...@bitplanet.net> > --- > src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 18 +++++++++++++++--- > 1 file changed, 15 insertions(+), 3 deletions(-) > > diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp > b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp > index dd4beff..9c4f5e8 100644 > --- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp > +++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp > @@ -426,8 +426,11 @@ 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) { > + bool mul_negate = false, mul_abs = false; > + if (mul && mul->operation == ir_unop_abs) { > + mul = mul->operands[0]->as_expression(); > + mul_abs = true; > + } else if (mul && mul->operation == ir_unop_neg) { > mul = mul->operands[0]->as_expression(); > mul_negate = true; > } > @@ -436,7 +439,10 @@ fs_visitor::try_emit_mad(ir_expression *ir) > nonmul = ir->operands[0]; > mul = ir->operands[1]->as_expression(); > > - if (mul && mul->operation == ir_unop_neg) { > + if (mul && mul->operation == ir_unop_abs) { > + mul = mul->operands[0]->as_expression(); > + mul_abs = true; > + } else if (mul && mul->operation == ir_unop_neg) { > mul = mul->operands[0]->as_expression(); > mul_negate = true; > } > @@ -456,9 +462,15 @@ fs_visitor::try_emit_mad(ir_expression *ir) > mul->operands[0]->accept(this); > fs_reg src1 = this->result; > src1.negate ^= mul_negate; > + src1.abs = mul_abs; > + if (mul_abs) > + src1.negate = false; > > mul->operands[1]->accept(this); > fs_reg src2 = this->result; > + src2.abs = mul_abs; > + if (mul_abs) > + src2.negate = false; > > this->result = fs_reg(this, ir->type); > emit(BRW_OPCODE_MAD, this->result, src0, src1, src2); > -- > 2.0.4 > > _______________________________________________ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/mesa-dev _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev