re PR tree-optimization/43842 (ice in vect_create_epilog_for_reduction)
authorIra Rosen <irar@il.ibm.com>
Thu, 22 Apr 2010 18:03:01 +0000 (18:03 +0000)
committerIra Rosen <irar@gcc.gnu.org>
Thu, 22 Apr 2010 18:03:01 +0000 (18:03 +0000)
PR tree-optimization/43842
* tree-vect-loop.c (vect_create_epilog_for_reduction): Handle
loop unrolling in update of exit phis. Fix comment.
* tree-vect-slp.c (vect_analyze_slp): Check that there are at
least two reduction statements in the loop before starting SLP
analysis.

From-SVN: r158650

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/vect/pr43842.c [new file with mode: 0644]
gcc/tree-vect-loop.c
gcc/tree-vect-slp.c

index 5d6a5df69557874bea71b04012f2001213fb4e5d..91cc23621431b74017f59a8de0007e2b10881e2d 100644 (file)
@@ -1,3 +1,12 @@
+2010-04-22 Ira Rosen <irar@il.ibm.com>
+
+       PR tree-optimization/43482
+       * tree-vect-loop.c (vect_create_epilog_for_reduction): Handle 
+       loop unrolling in update of exit phis. Fix comment.
+       * tree-vect-slp.c (vect_analyze_slp): Check that there are at
+       least two reduction statements in the loop before starting SLP 
+       analysis.
+
 2010-04-22  Nick Clifton  <nickc@redhat.com>
 
        * config/stormy16/stormy16-lib2.c (__ucmpsi2): Fix thinko.
index 41156bb6b52a8b8b189fc07ae989d9ec03440ef2..d21af46c2094990f03a69f5108bd9336d57b21aa 100644 (file)
@@ -1,3 +1,8 @@
+2010-04-22 Ira Rosen <irar@il.ibm.com>
+
+       PR tree-optimization/43482
+       * gcc.dg/vect/pr43842.c: New test.
+
 2010-04-22  Bernd Schmidt  <bernds@codesourcery.com>
 
        * gcc.target/i386/wmul-1.c: Add dg-require-effective-target ilp32.
diff --git a/gcc/testsuite/gcc.dg/vect/pr43842.c b/gcc/testsuite/gcc.dg/vect/pr43842.c
new file mode 100644 (file)
index 0000000..593404f
--- /dev/null
@@ -0,0 +1,55 @@
+/* { dg-do compile } */
+
+typedef char int8_t;
+typedef short int int16_t;
+typedef int int32_t;
+typedef unsigned char uint8_t;
+typedef unsigned short int uint16_t;
+typedef unsigned int uint32_t;
+
+static int16_t
+safe_rshift_func_int16_t_s_u (int16_t left, unsigned int right)
+{
+  return left || right >= 1 * 8 ? left : left >> right;
+}
+
+static int8_t
+safe_rshift_func_int8_t_s_u (int8_t left, unsigned int right)
+{
+  return left || right >= 1 * 8 ? left : left >> right;
+}
+
+
+static uint32_t
+safe_add_func_uint32_t_u_u (uint32_t ui1, uint16_t ui2)
+{
+  return ui1 + ui2;
+}
+
+int16_t g_4;
+int8_t g_4_8;
+uint32_t g_9[1];
+uint32_t g_9_8[2];
+int161 (void)
+{
+  int32_t l_2;
+
+  for (l_2 = -25; l_2; l_2 = safe_add_func_uint32_t_u_u (l_2, 1))
+    g_9[0] ^= safe_rshift_func_int16_t_s_u (g_4, 1);
+}
+
+int81 (void)
+{
+  int32_t l_2;
+
+  for (l_2 = -25; l_2; l_2 = safe_add_func_uint32_t_u_u (l_2, 1))
+    {
+      g_9[0] ^= safe_rshift_func_int8_t_s_u (g_4_8, 1);
+      g_9[1] ^= safe_rshift_func_int8_t_s_u (g_4_8, 1);
+    }
+
+  return 0;
+}
+
+/* { dg-final { cleanup-tree-dump "vect" } } */
+
index e6e9008ea3774eea8a670fd8c08b66231605200d..83b823d84bfed060645250ce0950ec27ac749c4d 100644 (file)
@@ -2961,7 +2961,7 @@ vect_create_epilog_for_reduction (VEC (tree, heap) *vect_defs, gimple stmt,
   enum vect_def_type dt = vect_unknown_def_type;
   int j, i;
   VEC (tree, heap) *scalar_results = NULL;
-  int group_size = 1, k, ratio;
+  unsigned int group_size = 1, k, ratio;
   VEC (tree, heap) *vec_initial_defs = NULL;
   VEC (gimple, heap) *phis;
 
@@ -3439,7 +3439,8 @@ vect_finalize_reduction:
           v_out2 = reduce <v_out1>
           s_out3 = extract_field <v_out2, 0>
           s_out4 = adjust_result <s_out3>
-          use <s_out4>  */
+          use <s_out4>  
+          use <s_out4> */
 
   /* In SLP we may have several statements in NEW_PHIS and REDUCTION_PHIS (in 
      case that GROUP_SIZE is greater than vectorization factor). Therefore, we
@@ -3447,8 +3448,13 @@ vect_finalize_reduction:
      (GROUP_SIZE / number of new vector stmts) scalar results correspond to
      the first vector stmt, etc.  
      (RATIO is equal to (GROUP_SIZE / number of new vector stmts)).  */ 
-  ratio = group_size / VEC_length (gimple, new_phis);
-  gcc_assert (!(group_size % VEC_length (gimple, new_phis)));
+  if (group_size > VEC_length (gimple, new_phis))
+    {
+      ratio = group_size / VEC_length (gimple, new_phis);
+      gcc_assert (!(group_size % VEC_length (gimple, new_phis)));
+    }
+  else
+    ratio = 1;
 
   for (k = 0; k < group_size; k++)
     {
index 99a865fee20f1c6446ce857b46195a5d701e6395..6949ebdf8730cd8aa742128513e6eec7841245b9 100644 (file)
@@ -1213,7 +1213,7 @@ vect_analyze_slp (loop_vec_info loop_vinfo, bb_vec_info bb_vinfo)
     }
 
   /* Find SLP sequences starting from groups of reductions.  */
-  if (loop_vinfo &&  VEC_length (gimple, LOOP_VINFO_REDUCTIONS (loop_vinfo))
+  if (loop_vinfo && VEC_length (gimple, LOOP_VINFO_REDUCTIONS (loop_vinfo)) > 1
       && vect_analyze_slp_instance (loop_vinfo, bb_vinfo, 
                                     VEC_index (gimple, reductions, 0)))
     ok = true;