[Mesa-dev] [PATCH] i965/vec4: Detect and delete useless MOVs.

Jason Ekstrand jason at jlekstrand.net
Mon Sep 21 14:18:08 PDT 2015


On Mon, Sep 21, 2015 at 2:17 PM, Jason Ekstrand <jason at jlekstrand.net> wrote:
> On Mon, Sep 21, 2015 at 2:16 PM, Kenneth Graunke <kenneth at whitecape.org> wrote:
>> On Monday, September 21, 2015 02:04:00 PM Matt Turner wrote:
>>> With NIR:
>>>
>>> instructions in affected programs:     111508 -> 109193 (-2.08%)
>>> helped:                                507
>>>
>>> Without NIR:
>>>
>>> instructions in affected programs:     28763 -> 28474 (-1.00%)
>>> helped:                                186
>>> ---
>>>  src/mesa/drivers/dri/i965/brw_vec4.cpp | 21 +++++++++++++++++++++
>>>  1 file changed, 21 insertions(+)
>>>
>>> diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp b/src/mesa/drivers/dri/i965/brw_vec4.cpp
>>> index ed49cd3..d09a8dd 100644
>>> --- a/src/mesa/drivers/dri/i965/brw_vec4.cpp
>>> +++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp
>>> @@ -1021,6 +1021,27 @@ vec4_visitor::opt_register_coalesce()
>>>         inst->src[0].abs || inst->src[0].negate || inst->src[0].reladdr)
>>>        continue;
>>>
>>> +      if (inst->dst.file == inst->src[0].file &&
>>> +          inst->dst.reg == inst->src[0].reg &&
>>> +          inst->dst.reg_offset == inst->src[0].reg_offset) {
>>> +         bool is_nop_mov = true;
>>> +
>>> +         for (unsigned c = 0; c < 4; c++) {
>>> +            if ((inst->dst.writemask & (1 << c)) == 0)
>>> +               continue;
>>> +
>>> +            if (BRW_GET_SWZ(inst->src[0].swizzle, c) != c) {
>>> +               is_nop_mov = false;
>>> +               break;
>>> +            }
>>> +         }
>>> +
>>> +         if (is_nop_mov) {
>>> +            inst->remove(block);
>>> +            continue;
>>> +         }
>>> +      }
>>> +
>>>        bool to_mrf = (inst->dst.file == MRF);
>>>
>>>        /* Can't coalesce this GRF if someone else was going to
>>>
>>
>> Seems like this would break for:
>>
>>    mov(8) g2<1>F g2.xyzw<4,4,1>D
>>
>> or
>>
>>    mov(8) g2<1>F -|g2.xyzw|<4,4,1>F
>>
>> Did I miss something?
>
> Right above there, we bail if inst->dst.type != inst->src[0].type

And source modifiers and a few other conditions.


More information about the mesa-dev mailing list