[Mesa-dev] [PATCH 3/3] i965: Emit MUL with a negated src for neg(mul(...)).

Matt Turner mattst88 at gmail.com
Wed Feb 11 16:11:00 PST 2015


On Wed, Feb 11, 2015 at 3:57 PM, Ian Romanick <idr at freedesktop.org> wrote:
> On 02/11/2015 02:54 PM, Matt Turner wrote:
>> total instructions in shared programs: 5932832 -> 5932736 (-0.00%)
>> instructions in affected programs:     8184 -> 8088 (-1.17%)
>> helped:                                52
>> HURT:                                  14
>> GAINED:                                1
>> ---
>>  src/mesa/drivers/dri/i965/brw_fs_visitor.cpp   | 14 ++++++++++++++
>>  src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 19 +++++++++++++++++++
>>  2 files changed, 33 insertions(+)
>>
>> diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
>> index b628bff..17849c7 100644
>> --- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
>> +++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
>> @@ -630,6 +630,20 @@ fs_visitor::visit(ir_expression *ir)
>>
>>     /* Deal with the real oddball stuff first */
>>     switch (ir->operation) {
>> +   case ir_unop_neg: {
>> +      if (!ir->type->is_float())
>> +         break;
>> +
>> +      ir_expression *mul = ir->operands[0]->as_expression();
>> +      if (mul && mul->operation == ir_binop_mul) {
>> +         mul->accept(this);
>> +         fs_inst *mul_inst = (fs_inst *) this->instructions.get_tail();
>> +         assert(mul_inst->opcode == BRW_OPCODE_MUL);
>> +
>> +         mul_inst->src[1].negate = true;
>
> Are you sure that mul_inst->src[1].negate will be false?

Yes. We used to modify existing operands' negate field in place when
we visited ir_unop_neg, but with commit 0ae9ca12 I changed it so that
we always emit a MOV.

> Also, shouldn't this return here?  The other cases return when they are
> able to generate code for the expression.

Yes, thanks.


More information about the mesa-dev mailing list