Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

2016-03-09  Richard Biener  <rguent...@suse.de>
        Jakub Jelinek  <ja...@redhat.com>

        PR tree-optimization/70138
        * tree-vect-loop-manip.c (vect_update_ivs_after_vectorizer):
        Also skip vect_double_reduction_def.

        * gcc.dg/vect/pr70138-1.c: New testcase.
        * gcc.dg/vect/pr70138-2.c: Likewise.

Index: gcc/tree-vect-loop-manip.c
===================================================================
*** gcc/tree-vect-loop-manip.c  (revision 234085)
--- gcc/tree-vect-loop-manip.c  (working copy)
*************** vect_update_ivs_after_vectorizer (loop_v
*** 1692,1698 ****
  
        /* Skip reduction phis.  */
        stmt_info = vinfo_for_stmt (phi);
!       if (STMT_VINFO_DEF_TYPE (stmt_info) == vect_reduction_def)
          {
          if (dump_enabled_p ())
            dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
--- 1687,1694 ----
  
        /* Skip reduction phis.  */
        stmt_info = vinfo_for_stmt (phi);
!       if (STMT_VINFO_DEF_TYPE (stmt_info) == vect_reduction_def
!         || STMT_VINFO_DEF_TYPE (stmt_info) == vect_double_reduction_def)
          {
          if (dump_enabled_p ())
            dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
Index: gcc/testsuite/gcc.dg/vect/pr70138-1.c
===================================================================
*** gcc/testsuite/gcc.dg/vect/pr70138-1.c       (revision 0)
--- gcc/testsuite/gcc.dg/vect/pr70138-1.c       (working copy)
***************
*** 0 ****
--- 1,40 ----
+ /* { dg-do run } */
+ 
+ #include "tree-vect.h"
+ 
+ double u[33 * 33];
+ 
+ __attribute__((noinline, noclone)) static void
+ foo (int *x)
+ {
+   double c = 0.0;
+   int a, b;
+   for (a = 0; a < 33; a++)
+     {
+       for (b = 0; b < 33; b++)
+       c = c + u[34 * a];
+       u[34 * a] *= 2.0;
+     }
+   *x = c;
+ }
+ 
+ int
+ main ()
+ {
+   int d, e;
+   check_vect ();
+   for (d = 0; d < 33 * 33; d++)
+     {
+       u[d] = 499.0;
+       __asm__ volatile ("" : : : "memory");
+     }
+   for (d = 0; d < 33; d++)
+     {
+       u[d * 34] = (d + 2);
+       __asm__ volatile ("" : : : "memory");
+     }
+   foo (&e);
+   if (e != 33 * (2 + 34) / 2 * 33)
+     __builtin_abort ();
+   return 0;
+ }
Index: gcc/testsuite/gcc.dg/vect/pr70138-2.c
===================================================================
*** gcc/testsuite/gcc.dg/vect/pr70138-2.c       (revision 0)
--- gcc/testsuite/gcc.dg/vect/pr70138-2.c       (working copy)
***************
*** 0 ****
--- 1,35 ----
+ /* { dg-do run } */
+ 
+ #include "tree-vect.h"
+ 
+ double u[33];
+ 
+ __attribute__((noinline, noclone)) static void
+ foo (int *x)
+ {
+   double c = 0.0;
+   int a, b;
+   for (a = 0; a < 33; a++)
+     {
+       for (b = 0; b < 33; b++)
+       c = c + u[a];
+       u[a] *= 2.0;
+     }
+   *x = c;
+ }
+ 
+ int
+ main ()
+ {
+   int d, e;
+   check_vect ();
+   for (d = 0; d < 33; d++)
+     {
+       u[d] = (d + 2);
+       __asm__ volatile ("" : : : "memory");
+     }
+   foo (&e);
+   if (e != 33 * (2 + 34) / 2 * 33)
+     __builtin_abort ();
+   return 0;
+ }

Reply via email to