[patch] Fix PR tree-optimization/40542 - prevent vectorization of volatile types

Richard Guenther rguenther@suse.de
Tue Jun 30 12:00:00 GMT 2009


On Tue, 30 Jun 2009, Ira Rosen wrote:

> 
> Hi,
> 
> This patch prevents vectorization of volatile types.
> Thanks to Richard for pointing out the API to use.
> 
> Bootstrapped with vectorization enabled and tested on x86_64-suse-linux for
> 4.3, 4.4 and 4.5.
> Committed to mainline.
> O.K. for 4.4 and 4.3?

Ok.

Thanks,
Richard.

> Thanks,
> Ira
> 
> 4.5:
> ChangeLog:
> 
>       PR tree-optimization/40542
>       * tree-vect-stmts.c (vect_analyze_stmt): Don't vectorize volatile
>       types.
> 
> testsuite/ChangeLog:
> 
>       PR tree-optimization/40542
>       * gcc.dg/vect/pr40542.c: New test.
> 
> Index: tree-vect-stmts.c
> ===================================================================
> --- tree-vect-stmts.c   (revision 149082)
> +++ tree-vect-stmts.c   (working copy)
> @@ -3910,6 +3910,14 @@ vect_analyze_stmt (gimple stmt, bool *ne
>        print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
>      }
> 
> +  if (gimple_has_volatile_ops (stmt))
> +    {
> +      if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
> +        fprintf (vect_dump, "not vectorized: stmt has volatile operands");
> +
> +      return false;
> +    }
> +
>    /* Skip stmts that do not need to be vectorized. In loops this is
> expected
>       to include:
>       - the COND_EXPR which is the loop exit condition
> Index: testsuite/gcc.dg/vect/pr40542.c
> ===================================================================
> --- testsuite/gcc.dg/vect/pr40542.c     (revision 0)
> +++ testsuite/gcc.dg/vect/pr40542.c     (revision 0)
> @@ -0,0 +1,14 @@
> +/* { dg-do compile } */
> +
> +void
> +volarr_cpy(char *d, volatile char *s)
> +{
> +  int i;
> +
> +  for (i = 0; i < 16; i++)
> +    d[i] = s[i];
> +}
> +
> +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail
> *-*-* } } } */
> +/* { dg-final { cleanup-tree-dump "vect" } } */
> +
> 
> 4.4:
> ChangeLog:
> 
>       PR tree-optimization/40542
>       * tree-vect-analyze.c (vect_determine_vectorization_factor): Don't
>       vectorize volatile types.
> 
> testsuite/ChangeLog:
> 
>       PR tree-optimization/40542
>       * gcc.dg/vect/pr40542.c: New test.
> 
> Index: tree-vect-analyze.c
> ===================================================================
> --- tree-vect-analyze.c (revision 149023)
> +++ tree-vect-analyze.c (working copy)
> @@ -199,6 +199,15 @@ vect_determine_vectorization_factor (loo
>               print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
>             }
> 
> +          if (gimple_has_volatile_ops (stmt))
> +            {
> +              if (vect_print_dump_info (REPORT_UNVECTORIZED_LOOPS))
> +                fprintf (vect_dump, "not vectorized: stmt has volatile"
> +                                    " operands");
> +
> +              return false;
> +            }
> +
>           gcc_assert (stmt_info);
> 
>           /* skip stmts which do not need to be vectorized.  */
> Index: testsuite/gcc.dg/vect/pr40542.c
> ===================================================================
> --- testsuite/gcc.dg/vect/pr40542.c     (revision 0)
> +++ testsuite/gcc.dg/vect/pr40542.c     (revision 0)
> @@ -0,0 +1,14 @@
> +/* { dg-do compile } */
> +
> +void
> +volarr_cpy(char *d, volatile char *s)
> +{
> +  int i;
> +
> +  for (i = 0; i < 16; i++)
> +    d[i] = s[i];
> +}
> +
> +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail
> *-*-* } } } */
> +/* { dg-final { cleanup-tree-dump "vect" } } */
> +
> 
> 4.3:
> ChangeLog:
> 
>       PR tree-optimization/40542
>       * tree-vect-analyze.c (vect_determine_vectorization_factor): Don't
>       vectorize volatile types.
> 
> testsuite/ChangeLog:
> 
>       PR tree-optimization/40542
>       * gcc.dg/vect/pr40542.c: New test.
> 
> Index: tree-vect-analyze.c
> ===================================================================
> --- tree-vect-analyze.c (revision 149023)
> +++ tree-vect-analyze.c (working copy)
> @@ -173,6 +173,15 @@ vect_determine_vectorization_factor (loo
>               print_generic_expr (vect_dump, stmt, TDF_SLIM);
>             }
> 
> +          if (stmt_ann (stmt)->has_volatile_ops)
> +            {
> +              if (vect_print_dump_info (REPORT_UNVECTORIZED_LOOPS))
> +                fprintf (vect_dump, "not vectorized: stmt has volatile"
> +                                    " operands");
> +
> +              return false;
> +            }
> +
>           gcc_assert (stmt_info);
> 
>           /* skip stmts which do not need to be vectorized.  */
> Index: testsuite/gcc.dg/vect/pr40542.c
> ===================================================================
> --- testsuite/gcc.dg/vect/pr40542.c     (revision 0)
> +++ testsuite/gcc.dg/vect/pr40542.c     (revision 0)
> @@ -0,0 +1,14 @@
> +/* { dg-do compile } */
> +
> +void
> +volarr_cpy(char *d, volatile char *s)
> +{
> +  int i;
> +
> +  for (i = 0; i < 16; i++)
> +    d[i] = s[i];
> +}
> +
> +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail
> *-*-* } } } */
> +/* { dg-final { cleanup-tree-dump "vect" } } */
> +
> 
> 

-- 
Richard Guenther <rguenther@suse.de>
Novell / SUSE Labs
SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746 - GF: Markus Rex



More information about the Gcc-patches mailing list