[Mesa-dev] [PATCH] i965/fs: Remove redundant hand-unrolled first iteration of loop.

Francisco Jerez currojerez at riseup.net
Mon Jul 20 07:56:02 PDT 2015


Francisco Jerez <currojerez at riseup.net> writes:

> This seems rather silly and would lead to memory corruption if the
> size of a VGRF was allowed to be zero.
> ---
>  src/mesa/drivers/dri/i965/brw_fs.cpp | 10 +++-------
>  1 file changed, 3 insertions(+), 7 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
> index 960ea54..eafd676 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
> @@ -1565,16 +1565,12 @@ fs_visitor::split_virtual_grfs()
>  
>     int reg = 0;
>     for (int i = 0; i < num_vars; i++) {
> +      int offset = 0;
> +
>        /* The first one should always be 0 as a quick sanity check. */
>        assert(split_points[reg] == false);
>  

For correctness I've also changed this assertion locally to read
"reg_count == reg || split_points[reg] == false".

> -      /* j = 0 case */
> -      new_reg_offset[reg] = 0;
> -      reg++;
> -      int offset = 1;
> -
> -      /* j > 0 case */
> -      for (unsigned j = 1; j < alloc.sizes[i]; j++) {
> +      for (unsigned j = 0; j < alloc.sizes[i]; j++) {
>           /* If this is a split point, reset the offset to 0 and allocate a
>            * new virtual GRF for the previous offset many registers
>            */
> -- 
> 2.4.3
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 212 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150720/e719aed0/attachment-0001.sig>


More information about the mesa-dev mailing list