[Mesa-dev] [PATCH] glsl: Avoid combining statements from different basic blocks.

Kenneth Graunke kenneth at whitecape.org
Mon Jan 27 21:16:09 PST 2014


On 01/27/2014 03:17 PM, Matt Turner wrote:
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=74113
> ---
>  src/glsl/opt_vectorize.cpp | 35 +++++++++++++++++++++++++++++++++++
>  1 file changed, 35 insertions(+)
> 
> diff --git a/src/glsl/opt_vectorize.cpp b/src/glsl/opt_vectorize.cpp
> index ac43a29..5ad1320 100644
> --- a/src/glsl/opt_vectorize.cpp
> +++ b/src/glsl/opt_vectorize.cpp
> @@ -82,6 +82,8 @@ public:
>  
>     virtual ir_visitor_status visit_enter(ir_assignment *);
>     virtual ir_visitor_status visit_enter(ir_swizzle *);
> +   virtual ir_visitor_status visit_enter(ir_if *);
> +   virtual ir_visitor_status visit_enter(ir_loop *);
>  
>     virtual ir_visitor_status visit_leave(ir_assignment *);
>  
> @@ -285,6 +287,39 @@ ir_vectorize_visitor::visit_enter(ir_swizzle *ir)
>     return visit_continue;
>  }
>  
> +/* Since there is no statement to visit between the "then" and "else"
> + * instructions try to vectorize before, in between, and after them to avoid
> + * combining statements from different basic blocks.
> + */
> +ir_visitor_status
> +ir_vectorize_visitor::visit_enter(ir_if *ir)
> +{
> +   try_vectorize();
> +
> +   visit_list_elements(this, &ir->then_instructions);
> +   try_vectorize();
> +
> +   visit_list_elements(this, &ir->else_instructions);
> +   try_vectorize();
> +
> +   return visit_continue_with_parent;
> +}
> +
> +/* Since there is no statement to visit between the instructions in the body of
> + * the loop and the instructions after it try to vectorize before and after the
> + * body to avoid combining statements from different basic blocks.
> + */
> +ir_visitor_status
> +ir_vectorize_visitor::visit_enter(ir_loop *ir)
> +{
> +   try_vectorize();
> +
> +   visit_list_elements(this, &ir->body_instructions);
> +   try_vectorize();
> +
> +   return visit_continue_with_parent;
> +}
> +
>  /**
>   * Upon leaving an ir_assignment, save a pointer to it in ::assignment[] if
>   * the swizzle mask(s) found were appropriate. Also save a pointer in
> 

Looks good to me.  Thanks Matt.

Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20140127/eefe3b14/attachment.pgp>


More information about the mesa-dev mailing list