re PR tree-optimization/49771 (wrong code with -ftree-vectorize)
authorIra Rosen <ira.rosen@linaro.org>
Tue, 19 Jul 2011 06:25:07 +0000 (06:25 +0000)
committerIra Rosen <irar@gcc.gnu.org>
Tue, 19 Jul 2011 06:25:07 +0000 (06:25 +0000)
        PR tree-optimization/49771
        * tree-vect-loop-manip.c (vect_vfa_segment_size): In case of
        zero step, set segment length to the size of the data-ref's type.

From-SVN: r176434

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

index f114c254423851b5949dbf86a2ea0e9f2a3e0b58..62293beeaa1f8dcafe221dbd6c86402d6751137f 100644 (file)
@@ -1,3 +1,9 @@
+2011-07-19  Ira Rosen  <ira.rosen@linaro.org>
+
+       PR tree-optimization/49771
+       * tree-vect-loop-manip.c (vect_vfa_segment_size): In case of
+       zero step, set segment length to the size of the data-ref's type.
+
 2011-07-18  Martin Jambor  <mjambor@suse.cz>
 
        * ipa-prop.h: Include alloc-pool.h, all sorts of updates to general
index 7ccdad4a835518fb65796391ede09e95f14129a6..ffc6f0baa7324304b9b531738bbfe97ce17a6971 100644 (file)
@@ -1,3 +1,8 @@
+2011-07-19  Ira Rosen  <ira.rosen@linaro.org>
+
+       PR tree-optimization/49771
+       * gcc.dg/vect/pr49771.c: New test.
+
 2011-07-18  Martin Jambor  <mjambor@suse.cz>
 
        * gcc.dg/ipa/ipa-1.c: Updated testcase dump scan.
diff --git a/gcc/testsuite/gcc.dg/vect/pr49771.c b/gcc/testsuite/gcc.dg/vect/pr49771.c
new file mode 100644 (file)
index 0000000..777f615
--- /dev/null
@@ -0,0 +1,26 @@
+#include <stdlib.h>
+#include <stdarg.h>
+
+static int a[1000];
+
+int
+foo (void)
+{
+  int j;
+  int i;
+  for (i = 0; i < 1000; i++)
+    for (j = 0; j < 1000; j++)
+      a[j] = a[i] + 1;
+  return a[0];
+}
+
+int
+main (void)
+{
+  int res = foo ();
+  if (res != 1999)
+    abort ();
+  return 0;
+}
+
+/* { dg-final { cleanup-tree-dump "vect" } } */
index b8d67804f77ecda6ea6d6c56d511c9aea5a01fd3..6039c1609f457fcc576f16a73ed93a9df86b1b20 100644 (file)
@@ -2356,9 +2356,14 @@ static tree
 vect_vfa_segment_size (struct data_reference *dr, tree length_factor)
 {
   tree segment_length;
-  segment_length = size_binop (MULT_EXPR,
-                              fold_convert (sizetype, DR_STEP (dr)),
-                              fold_convert (sizetype, length_factor));
+
+  if (!compare_tree_int (DR_STEP (dr), 0))
+    segment_length = TYPE_SIZE_UNIT (TREE_TYPE (DR_REF (dr)));
+  else
+    segment_length = size_binop (MULT_EXPR,
+                                 fold_convert (sizetype, DR_STEP (dr)),
+                                 fold_convert (sizetype, length_factor));
+
   if (vect_supportable_dr_alignment (dr, false)
         == dr_explicit_realign_optimized)
     {