i965/fs: Take into account trailing padding in regs_written() and regs_read().
authorFrancisco Jerez <currojerez@riseup.net>
Wed, 7 Sep 2016 21:33:55 +0000 (14:33 -0700)
committerFrancisco Jerez <currojerez@riseup.net>
Wed, 14 Sep 2016 21:50:54 +0000 (14:50 -0700)
commite540045df5cf5ae17ce640d6d73138444a4ac0d3
treed6bb0899132a1c44a88d3e30ecdff66ac3052e15
parent937373eb25c53b0803e526b7b273afc2b3330752
i965/fs: Take into account trailing padding in regs_written() and regs_read().

This fixes regs_written() and regs_read() to return a more accurate
value when the padding left between components due to a stride value
greater than one causes the region bounds given by size_written or
size_read to overflow into the next register.  This could become a
problem in optimization passes that keep track of dataflow using
fixed-size arrays with register granularity, because the overflow
register (not actually accessed by the region) may not have been
allocated at all which could lead to undefined memory access.

An alternative to this would be to subtract the trailing padding
already during the calculation of fs_inst::size_read and
::size_written, but that would break code that currently assumes that
::size_read and _written are whole multiples of the component size,
and would be hard to maintain looking forward because size_written is
assigned from a bunch of different places.

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
src/mesa/drivers/dri/i965/brw_ir_fs.h