re PR tree-optimization/40074 (ICE in vect_get_vec_def_for_operand, at tree-vect...
authorIra Rosen <irar@il.ibm.com>
Mon, 11 May 2009 12:33:13 +0000 (12:33 +0000)
committerIra Rosen <irar@gcc.gnu.org>
Mon, 11 May 2009 12:33:13 +0000 (12:33 +0000)
PR tree-optimization/40074
* tree-vect-data-refs.c (vect_analyze_group_access): Take gaps into
account in group size and step comparison.

From-SVN: r147372

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/vect/pr40074.c [new file with mode: 0644]
gcc/tree-vect-data-refs.c

index 71052b1..f33d4b0 100644 (file)
@@ -1,3 +1,9 @@
+2009-05-11  Ira Rosen  <irar@il.ibm.com>
+
+       PR tree-optimization/40074
+       * tree-vect-data-refs.c (vect_analyze_group_access): Take gaps into
+       account in group size and step comparison.
+
 2009-05-11  Richard Guenther  <rguenther@suse.de>
 
        * passes.c (init_optimization_passes): Strip now incorrect comment.
index ca5cf9f..1ccd97a 100644 (file)
@@ -1,3 +1,8 @@
+2009-05-11  Ira Rosen  <irar@il.ibm.com>
+
+       PR tree-optimization/40074
+       * gcc.dg/vect/pr40074.c: New test.
+
 2009-05-10  Ian Lance Taylor  <iant@google.com>
 
        * gcc.dg/Wcxx-compat-7.c: New testcase.
diff --git a/gcc/testsuite/gcc.dg/vect/pr40074.c b/gcc/testsuite/gcc.dg/vect/pr40074.c
new file mode 100644 (file)
index 0000000..6459f1b
--- /dev/null
@@ -0,0 +1,54 @@
+/* { dg-require-effective-target vect_int } */
+
+#include <stdarg.h>
+#include "tree-vect.h"
+
+#define N 16 
+
+typedef struct {
+   int a;
+   int b;
+   int c;
+   int d;
+} s;
+
+
+s arr[N] = {{7,0,1,5}, {7,2,3,5}, {7,4,5,5}, {7,6,7,5}, {7,8,9,5}, {7,10,11,5}, {7,12,13,5}, {7,14,15,5}, {7,16,17,5}, {7,18,19,5}, {7,20,21,5}, {7,22,23,5}, {7,24,25,5}, {7,26,27,5}, {7,28,29,5}, {7,30,31,5}};
+
+__attribute__ ((noinline)) int
+main1 ()
+{
+  s *p = arr, *q = arr + 1;
+  int res[N];
+  int i;
+
+  for (i = 0; i < N-1; i++)
+    {
+      res[i] = p->b + p->d + q->b;
+      p++;
+      q++;
+    }
+  
+  /* check results:  */
+  for (i = 0; i < N-1; i++)
+    {
+      if (res[i] != arr[i].b + arr[i].d + arr[i+1].b)
+       abort ();
+    }
+
+  return 0;
+}
+
+int main (void)
+{
+  int i;
+  
+  check_vect ();
+
+  main1 ();
+
+  return 0;
+}
+
+/* { dg-final { cleanup-tree-dump "vect" } } */
+  
index a117898..42854a0 100644 (file)
@@ -1424,7 +1424,7 @@ vect_analyze_group_access (struct data_reference *dr)
       /* First stmt in the interleaving chain. Check the chain.  */
       gimple next = DR_GROUP_NEXT_DR (vinfo_for_stmt (stmt));
       struct data_reference *data_ref = dr;
-      unsigned int count = 1;
+      unsigned int count = 1, gaps = 0;
       tree next_step;
       tree prev_init = DR_INIT (data_ref);
       gimple prev = stmt;
@@ -1490,6 +1490,8 @@ vect_analyze_group_access (struct data_reference *dr)
                    fprintf (vect_dump, "interleaved store with gaps");
                  return false;
                }
+
+              gaps += diff - 1;
            }
 
           /* Store the gap from the previous member of the group. If there is no
@@ -1506,8 +1508,9 @@ vect_analyze_group_access (struct data_reference *dr)
          the type to get COUNT_IN_BYTES.  */
       count_in_bytes = type_size * count;
 
-      /* Check that the size of the interleaving is not greater than STEP.  */
-      if (dr_step < count_in_bytes)
+     /* Check that the size of the interleaving (including gaps) is not greater
+         than STEP.  */
+      if (dr_step && dr_step < count_in_bytes + gaps * type_size)
         {
           if (vect_print_dump_info (REPORT_DETAILS))
             {