This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fixing PR60000: A bug in the vectorizer.


On Thu, 30 Jan 2014, Cong Hou wrote:

> Hi
> 
> PR60000 (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60000) is caused by
> GCC vectorizer. The bug appears when handling vectorization patterns. When
> a pattern statement has additional new statements stored in pattern_def_seq
> in vect_transform_loop(), those statements are vectorized before the
> pattern statement. Once all those statements are handled, pattern_def_seq
> is set to NULL. However, if the pattern statement is a store,
> pattern_def_seq will not be set to NULL. In consequence, the next pattern
> statement will not have the correct pattern_def_seq

Is that because si and pattern_def_si point to the same stmts?  Then
I'd prefer to do

  if (is_store)
   {
     ...
     pattern_def_seq = NULL;
   }
 else if (!transform_pattern_stmt && gsi_end_p (pattern_def_si))
   {
     pattern_def_seq = NULL;
     gsi_next (&si);
   }

Richard.

> 
> This bug can be fixed by nullifying pattern_def_seq before checking if the
> vectorized statement is a store. The patch is pasted below. Bootstrapped
> and tested on x86_64.
> 
> 
> thanks,
> Cong
> 
> 
> 
> diff --git a/gcc/ChangeLog b/gcc/ChangeLog
> index 95a324c..9df0d34 100644
> --- a/gcc/ChangeLog
> +++ b/gcc/ChangeLog
> @@ -1,3 +1,10 @@
> +2014-01-30  Cong Hou  <congh@google.com>
> +
> +       PR tree-optimization/60000
> +       * tree-vect-loop.c (vect_transform_loop): Set pattern_def_seq to
> NULL
> +       before checking if the vectorized statement is a store. A store
> +       statement can be a pattern one.
> +
>  2014-01-27  Jakub Jelinek  <jakub@redhat.com>
> 
>         PR bootstrap/59934
> diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
> index fa61d5c..f2ce70f 100644
> --- a/gcc/testsuite/ChangeLog
> +++ b/gcc/testsuite/ChangeLog
> @@ -1,3 +1,8 @@
> +2014-01-30  Cong Hou  <congh@google.com>
> +
> +       PR tree-optimization/60000
> +       * g++.dg/vect/pr60000.cc: New test.
> +
>  2014-01-27  Christian Bruel  <christian.bruel@st.com>
> 
>         * gcc.target/sh/torture/strncmp.c: New tests.
> diff --git a/gcc/testsuite/g++.dg/vect/pr60000.cc
> b/gcc/testsuite/g++.dg/vect/pr60000.cc
> new file mode 100644
> index 0000000..8a8bd22
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/vect/pr60000.cc
> @@ -0,0 +1,13 @@
> +/* { dg-do compile } */
> +/* { dg-additional-options "-fno-tree-vrp" } */
> +
> +void foo (bool* a, int* b)
> +{
> +  for (int i = 0; i < 1000; ++i)
> +    {
> +      a[i] = i % 2;
> +      b[i] = i % 3;
> +    }
> +}
> +
> +/* { dg-final { cleanup-tree-dump "vect" } } */
> diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
> index 69c8d21..8c8bece 100644
> --- a/gcc/tree-vect-loop.c
> +++ b/gcc/tree-vect-loop.c
> @@ -6044,6 +6044,10 @@ vect_transform_loop (loop_vec_info loop_vinfo)
> 
>           grouped_store = false;
>           is_store = vect_transform_stmt (stmt, &si, &grouped_store, NULL,
> NULL);
> +
> +         if (!transform_pattern_stmt && gsi_end_p (pattern_def_si))
> +           pattern_def_seq = NULL;
> +
>            if (is_store)
>              {
>               if (STMT_VINFO_GROUPED_ACCESS (stmt_info))
> @@ -6068,10 +6072,7 @@ vect_transform_loop (loop_vec_info loop_vinfo)
>             }
> 
>           if (!transform_pattern_stmt && gsi_end_p (pattern_def_si))
> -           {
> -             pattern_def_seq = NULL;
> -             gsi_next (&si);
> -           }
> +           gsi_next (&si);
>         }                       /* stmts in BB */
>      }                          /* BBs in loop */
> 

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]