[Mesa-dev] [PATCH 26/32] i965/vec4: Don't assume a value is dead when its VGRF is only partially overwritten.

Francisco Jerez currojerez at riseup.net
Sun Feb 8 14:45:59 PST 2015


Matt Turner <mattst88 at gmail.com> writes:

> On Fri, Feb 6, 2015 at 6:43 AM, Francisco Jerez <currojerez at riseup.net> wrote:
>> ---
>>  src/mesa/drivers/dri/i965/brw_vec4_dead_code_eliminate.cpp | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/src/mesa/drivers/dri/i965/brw_vec4_dead_code_eliminate.cpp b/src/mesa/drivers/dri/i965/brw_vec4_dead_code_eliminate.cpp
>> index 9604e60..5df0d31 100644
>> --- a/src/mesa/drivers/dri/i965/brw_vec4_dead_code_eliminate.cpp
>> +++ b/src/mesa/drivers/dri/i965/brw_vec4_dead_code_eliminate.cpp
>> @@ -122,7 +122,8 @@ vec4_visitor::dead_code_eliminate()
>>              }
>>           }
>>
>> -         if (inst->dst.file == GRF && !inst->predicate) {
>> +         if (inst->dst.file == GRF && !inst->predicate &&
>> +             inst->regs_written == alloc.sizes[inst->dst.reg]) {
>>              for (int c = 0; c < 4; c++) {
>>                 if (inst->dst.writemask & (1 << c)) {
>>                    int var = inst->dst.reg * 4 + c;
>> --
>> 2.1.3
>
> I think what you're saying is that if an instruction wrote less than
> the size of the destination register we would incorrectly mark it as
> entirely overwritten?
>
Yes, exactly.

> I'm not reading the code that way. It looks like we're just marking
> individual channels (i.e., channels of the writemask) as dead. I don't
> see, for example, us using the size of the destination register
> anywhere in the loop.
>
> How you triggered this, again, would be helpful.

The problem is that the current dead code elimination code doesn't take
into account that VGRFs could be larger than one register (and, ugh,
neither does the VEC4 live interval calculation code), so it will think
that a value spanning several registers is dead after any of the
registers is overwritten.

I started fixing the live intervals code and got distracted by something
higher-priority while I was in the middle of fixing the million
assumptions I broke by changing the granularity of the intervals.  In
the meantime this should keep dead code eliminate from eliminating live
instructions that write to several registers.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 212 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150209/c47626a6/attachment.sig>


More information about the mesa-dev mailing list