public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix leaks in vectorizable_shift (PR middle-end/56461)
@ 2013-03-01 20:05 Jakub Jelinek
  2013-03-04  9:59 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2013-03-01 20:05 UTC (permalink / raw)
  To: Richard Biener; +Cc: gcc-patches

Hi!

Except for the case when we set vec_oprnd1 to non-NULL, with j == 0
we always initialize vec_oprnds[01] with vect_get_vec_defs, which overwrites
the vectors rather than just filling them.  So we shouldn't allocate the
vectors first.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2013-03-01  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/56461
	* tree-vect-stmts.c (vectorizable_shift): Don't call create methods
	on vec_oprnds0 or vec_oprnds1 before loop, only call it on
	vec_oprnds1 right before pushing anything to it for
	scalar_shift_arg.

--- gcc/tree-vect-stmts.c.jj	2013-02-28 22:19:57.000000000 +0100
+++ gcc/tree-vect-stmts.c	2013-03-01 11:59:03.973792955 +0100
@@ -3335,21 +3335,6 @@ vectorizable_shift (gimple stmt, gimple_
   /* Handle def.  */
   vec_dest = vect_create_destination_var (scalar_dest, vectype);
 
-  /* Allocate VECs for vector operands.  In case of SLP, vector operands are
-     created in the previous stages of the recursion, so no allocation is
-     needed, except for the case of shift with scalar shift argument.  In that
-     case we store the scalar operand in VEC_OPRNDS1 for every vector stmt to
-     be created to vectorize the SLP group, i.e., SLP_NODE->VEC_STMTS_SIZE.
-     In case of loop-based vectorization we allocate VECs of size 1.  We
-     allocate VEC_OPRNDS1 only in case of binary operation.  */
-  if (!slp_node)
-    {
-      vec_oprnds0.create (1);
-      vec_oprnds1.create (1);
-    }
-  else if (scalar_shift_arg)
-    vec_oprnds1.create (slp_node->vec_stmts_size);
-
   prev_stmt_info = NULL;
   for (j = 0; j < ncopies; j++)
     {
@@ -3369,6 +3354,7 @@ vectorizable_shift (gimple stmt, gimple_
                     dump_printf_loc (MSG_NOTE, vect_location,
                                      "operand 1 using scalar mode.");
                   vec_oprnd1 = op1;
+                  vec_oprnds1.create (slp_node ? slp_node->vec_stmts_size : 1);
                   vec_oprnds1.quick_push (vec_oprnd1);
                   if (slp_node)
                     {

	Jakub

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix leaks in vectorizable_shift (PR middle-end/56461)
  2013-03-01 20:05 [PATCH] Fix leaks in vectorizable_shift (PR middle-end/56461) Jakub Jelinek
@ 2013-03-04  9:59 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2013-03-04  9:59 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc-patches

On Fri, 1 Mar 2013, Jakub Jelinek wrote:

> Hi!
> 
> Except for the case when we set vec_oprnd1 to non-NULL, with j == 0
> we always initialize vec_oprnds[01] with vect_get_vec_defs, which overwrites
> the vectors rather than just filling them.  So we shouldn't allocate the
> vectors first.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

Ok.

Thanks,
Richard.

> 2013-03-01  Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR middle-end/56461
> 	* tree-vect-stmts.c (vectorizable_shift): Don't call create methods
> 	on vec_oprnds0 or vec_oprnds1 before loop, only call it on
> 	vec_oprnds1 right before pushing anything to it for
> 	scalar_shift_arg.
> 
> --- gcc/tree-vect-stmts.c.jj	2013-02-28 22:19:57.000000000 +0100
> +++ gcc/tree-vect-stmts.c	2013-03-01 11:59:03.973792955 +0100
> @@ -3335,21 +3335,6 @@ vectorizable_shift (gimple stmt, gimple_
>    /* Handle def.  */
>    vec_dest = vect_create_destination_var (scalar_dest, vectype);
>  
> -  /* Allocate VECs for vector operands.  In case of SLP, vector operands are
> -     created in the previous stages of the recursion, so no allocation is
> -     needed, except for the case of shift with scalar shift argument.  In that
> -     case we store the scalar operand in VEC_OPRNDS1 for every vector stmt to
> -     be created to vectorize the SLP group, i.e., SLP_NODE->VEC_STMTS_SIZE.
> -     In case of loop-based vectorization we allocate VECs of size 1.  We
> -     allocate VEC_OPRNDS1 only in case of binary operation.  */
> -  if (!slp_node)
> -    {
> -      vec_oprnds0.create (1);
> -      vec_oprnds1.create (1);
> -    }
> -  else if (scalar_shift_arg)
> -    vec_oprnds1.create (slp_node->vec_stmts_size);
> -
>    prev_stmt_info = NULL;
>    for (j = 0; j < ncopies; j++)
>      {
> @@ -3369,6 +3354,7 @@ vectorizable_shift (gimple stmt, gimple_
>                      dump_printf_loc (MSG_NOTE, vect_location,
>                                       "operand 1 using scalar mode.");
>                    vec_oprnd1 = op1;
> +                  vec_oprnds1.create (slp_node ? slp_node->vec_stmts_size : 1);
>                    vec_oprnds1.quick_push (vec_oprnd1);
>                    if (slp_node)
>                      {
> 
> 	Jakub
> 
> 

-- 
Richard Biener <rguenther@suse.de>
SUSE / SUSE Labs
SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746
GF: Jeff Hawn, Jennifer Guild, Felix Imend

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-03-04  9:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-01 20:05 [PATCH] Fix leaks in vectorizable_shift (PR middle-end/56461) Jakub Jelinek
2013-03-04  9:59 ` Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).