Patchwork Tidy dr_chain allocation in vectorizable_load

login
register
mail settings
Submitter Richard Sandiford
Date April 12, 2011, 1:09 p.m.
Message ID <g4tye3fwf0.fsf@linaro.org>
Download mbox | patch
Permalink /patch/90779/
State New
Headers show

Comments

Richard Sandiford - April 12, 2011, 1:09 p.m.
vectorizable_load allocates n_copies+1 dr_chains, even though only
the first n_copies are needed.  This patch removes the extra one and
IMO makes the flow a bit more obvious.

Tested on x86_64-linux-gnu and arm-linux-gnueabi.  OK to install?

Richard


gcc/
	* tree-vect-stmts.c (vectorizable_load): Allocate and free dr_chain
	within the per-copy loop.
Richard Guenther - April 12, 2011, 1:20 p.m.
On Tue, Apr 12, 2011 at 3:09 PM, Richard Sandiford
<richard.sandiford@linaro.org> wrote:
> vectorizable_load allocates n_copies+1 dr_chains, even though only
> the first n_copies are needed.  This patch removes the extra one and
> IMO makes the flow a bit more obvious.
>
> Tested on x86_64-linux-gnu and arm-linux-gnueabi.  OK to install?

Ok.

Thanks,
Richard.

> Richard
>
>
> gcc/
>        * tree-vect-stmts.c (vectorizable_load): Allocate and free dr_chain
>        within the per-copy loop.
>
> Index: gcc/tree-vect-stmts.c
> ===================================================================
> --- gcc/tree-vect-stmts.c       2011-04-12 11:55:07.000000000 +0100
> +++ gcc/tree-vect-stmts.c       2011-04-12 11:55:08.000000000 +0100
> @@ -3961,8 +3961,6 @@ vectorizable_load (gimple stmt, gimple_s
>        }
>       else
>        vec_num = group_size;
> -
> -      dr_chain = VEC_alloc (tree, heap, vec_num);
>     }
>   else
>     {
> @@ -4116,6 +4114,9 @@ vectorizable_load (gimple stmt, gimple_s
>         dataref_ptr =
>                bump_vector_ptr (dataref_ptr, ptr_incr, gsi, stmt, NULL_TREE);
>
> +      if (strided_load || slp_perm)
> +       dr_chain = VEC_alloc (tree, heap, vec_num);
> +
>       for (i = 0; i < vec_num; i++)
>        {
>          if (i > 0)
> @@ -4325,8 +4326,6 @@ vectorizable_load (gimple stmt, gimple_s
>                return false;
>
>              *vec_stmt = STMT_VINFO_VEC_STMT (stmt_info);
> -              VEC_free (tree, heap, dr_chain);
> -             dr_chain = VEC_alloc (tree, heap, group_size);
>            }
>           else
>            {
> @@ -4337,11 +4336,10 @@ vectorizable_load (gimple stmt, gimple_s
>              prev_stmt_info = vinfo_for_stmt (new_stmt);
>            }
>         }
> +      if (dr_chain)
> +       VEC_free (tree, heap, dr_chain);
>     }
>
> -  if (dr_chain)
> -    VEC_free (tree, heap, dr_chain);
> -
>   return true;
>  }
>
>

Patch

Index: gcc/tree-vect-stmts.c
===================================================================
--- gcc/tree-vect-stmts.c	2011-04-12 11:55:07.000000000 +0100
+++ gcc/tree-vect-stmts.c	2011-04-12 11:55:08.000000000 +0100
@@ -3961,8 +3961,6 @@  vectorizable_load (gimple stmt, gimple_s
     	}
       else
 	vec_num = group_size;
-
-      dr_chain = VEC_alloc (tree, heap, vec_num);
     }
   else
     {
@@ -4116,6 +4114,9 @@  vectorizable_load (gimple stmt, gimple_s
         dataref_ptr =
 		bump_vector_ptr (dataref_ptr, ptr_incr, gsi, stmt, NULL_TREE);
 
+      if (strided_load || slp_perm)
+	dr_chain = VEC_alloc (tree, heap, vec_num);
+
       for (i = 0; i < vec_num; i++)
 	{
 	  if (i > 0)
@@ -4325,8 +4326,6 @@  vectorizable_load (gimple stmt, gimple_s
 	        return false;
 
 	      *vec_stmt = STMT_VINFO_VEC_STMT (stmt_info);
-              VEC_free (tree, heap, dr_chain);
-	      dr_chain = VEC_alloc (tree, heap, group_size);
 	    }
           else
 	    {
@@ -4337,11 +4336,10 @@  vectorizable_load (gimple stmt, gimple_s
 	      prev_stmt_info = vinfo_for_stmt (new_stmt);
 	    }
         }
+      if (dr_chain)
+	VEC_free (tree, heap, dr_chain);
     }
 
-  if (dr_chain)
-    VEC_free (tree, heap, dr_chain);
-
   return true;
 }