[Mesa-stable] [PATCH] i965/vec4: Ignore swizzle of VGRF for use by var_range_end().

Francisco Jerez currojerez at riseup.net
Fri Aug 19 05:33:16 UTC 2016


Matt Turner <mattst88 at gmail.com> writes:

> var_range_end(v, n) loops over the n components of variable number v and
> finds the maximum value, giving the last use of any component of v.
> Therefore it expects v to correspond to the variable associated with the
> .x channel of the VGRF.
>
> var_from_reg() however returns the variable for the first channel of the
> VGRF, post-swizzle.
>
> So, if the last register had a swizzle with y, z, or w in the swizzle
> component, we would read out of bounds. For any other register, we would
> read liveness information from the next register.
>
> The fix is to convert the src_reg to a dst_reg in order to call the
> dst_reg version of var_from_reg() that doesn't consider the swizzle.
>
> Cc: mesa-stable at lists.freedesktop.org
> ---
>  src/mesa/drivers/dri/i965/brw_vec4.cpp     | 2 +-
>  src/mesa/drivers/dri/i965/brw_vec4_cse.cpp | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp b/src/mesa/drivers/dri/i965/brw_vec4.cpp
> index 2cf0e17..a7398a7 100644
> --- a/src/mesa/drivers/dri/i965/brw_vec4.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp
> @@ -1111,7 +1111,7 @@ vec4_visitor::opt_register_coalesce()
>        /* Can't coalesce this GRF if someone else was going to
>         * read it later.
>         */
> -      if (var_range_end(var_from_reg(alloc, inst->src[0]), 4) > ip)
> +      if (var_range_end(var_from_reg(alloc, dst_reg(inst->src[0])), 4) > ip)
>  	 continue;
>  
>        /* We need to check interference with the final destination between this
> diff --git a/src/mesa/drivers/dri/i965/brw_vec4_cse.cpp b/src/mesa/drivers/dri/i965/brw_vec4_cse.cpp
> index 0c1f0c3..10898a5 100644
> --- a/src/mesa/drivers/dri/i965/brw_vec4_cse.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_vec4_cse.cpp
> @@ -246,7 +246,7 @@ vec4_visitor::opt_cse_local(bblock_t *block)
>               * more -- a sure sign they'll fail operands_match().
>               */
>              if (src->file == VGRF) {
> -               if (var_range_end(var_from_reg(alloc, *src), 4) < ip) {
> +               if (var_range_end(var_from_reg(alloc, dst_reg(*src)), 4) < ip) {
>                    entry->remove();
>                    ralloc_free(entry);
>                    break;

Thanks for tracking this down :), patch is:

Reviewed-by: Francisco Jerez <currojerez at riseup.net>

> -- 
> 2.7.3
>
> _______________________________________________
> mesa-stable mailing list
> mesa-stable at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-stable
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 212 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/mesa-stable/attachments/20160818/4e3e4e0a/attachment.sig>


More information about the mesa-stable mailing list