re PR tree-optimization/36098 (435.gromacs miscompares at -O3)
authorIra Rosen <irar@il.ibm.com>
Wed, 14 May 2008 12:28:53 +0000 (12:28 +0000)
committerIra Rosen <irar@gcc.gnu.org>
Wed, 14 May 2008 12:28:53 +0000 (12:28 +0000)
PR tree-optimization/36098
* tree-vect-analyze.c (vect_analyze_group_access): Set the gap
value for the first load in the group in case of a gap.
(vect_build_slp_tree): Check that there are no gaps in loads.

From-SVN: r135290

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/vect/O3-pr36098.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/vect/vect.exp
gcc/tree-vect-analyze.c

index 223fe39ad034d9d731d8a7c7d4c929c7965d0394..9e151ea6984c4964119cda86bf39cfc893b48830 100644 (file)
@@ -1,3 +1,10 @@
+2008-05-14  Ira Rosen  <irar@il.ibm.com>
+
+       PR tree-optimization/36098
+       * tree-vect-analyze.c (vect_analyze_group_access): Set the gap
+       value for the first load in the group in case of a gap.
+       (vect_build_slp_tree): Check that there are no gaps in loads.
+
 2008-05-14  Kenneth Zadeck <zadeck@naturalbridge.com>
 
        * doc/rtl.texi: Removed reference to REG_NO_CONFLICT notes.
index 05a2d2569a00e27d1fbce628fb3c0002df205871..bd147b45a52cb9ac9e1d9a2c8ef72165ec7c2830 100644 (file)
@@ -1,3 +1,9 @@
+2008-05-14  Ira Rosen  <irar@il.ibm.com>
+
+       PR tree-optimization/36098      
+       * gcc.dg/vect/vect.exp: Compile with -O3 all the tests named "O3-*".
+       * gcc.dg/vect/O3-pr36098.c: New test.
+
 2008-05-14  Samuel Tardieu  <sam@rfc1149.net>
 
        * gnat.dg/old_errors.ads, gnat.dg/old_errors.adb: New.
diff --git a/gcc/testsuite/gcc.dg/vect/O3-pr36098.c b/gcc/testsuite/gcc.dg/vect/O3-pr36098.c
new file mode 100644 (file)
index 0000000..1c445be
--- /dev/null
@@ -0,0 +1,22 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target vect_int } */
+
+typedef struct {
+  int iatom[3];
+  int blocknr;
+} t_sortblock;
+
+#define DIM 3
+
+void foo (int ncons, t_sortblock *sb, int *iatom)
+{
+ int i, m;
+
+ for(i=0; (i<ncons); i++,iatom+=3)
+   for(m=0; (m<DIM); m++)
+     iatom[m]=sb[i].iatom[m];
+}
+
+/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { xfail *-*-* } } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
+
index 18877095fa9dfe8436382658810d1188ec786b61..2fb14b1b08ea041414f65784d3c61547a212a84c 100644 (file)
@@ -245,7 +245,7 @@ dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/Os-vect-*.\[cS\]]]  \
 # With -O3
 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
 lappend DEFAULT_VECTCFLAGS "-O3"
-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/O3-vect-*.\[cS\]]]  \
+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/O3-*.\[cS\]]]  \
         "" $DEFAULT_VECTCFLAGS
 
 # With -O1
index 0ef7f9cc4442598ff596894400cfaef5c4b09723..1e2012f85d19c53bc498460757e31e1de7ef08e8 100644 (file)
@@ -2230,7 +2230,13 @@ vect_analyze_group_access (struct data_reference *dr)
       if (dr_step != count_in_bytes)
         {
           if (DR_IS_READ (dr))
-            slp_impossible = true;
+            {
+              slp_impossible = true;
+              /* There is a gap after the last load in the group. This gap is a
+                 difference between the stride and the number of elements. When 
+                 there is no gap, this difference should be 0.  */ 
+              DR_GROUP_GAP (vinfo_for_stmt (stmt)) = stride - count; 
+            }
           else
             {
               if (vect_print_dump_info (REPORT_DETAILS))
@@ -2644,7 +2650,7 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, slp_tree *node,
   enum machine_mode vec_mode;
   tree first_stmt_const_oprnd = NULL_TREE;
   struct data_reference *first_dr;
+
   /* For every stmt in NODE find its def stmt/s.  */
   for (i = 0; VEC_iterate (tree, stmts, i, stmt); i++)
     {
@@ -2776,15 +2782,17 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, slp_tree *node,
                if (i == 0)
                  {
                    /* First stmt of the SLP group should be the first load of 
-                      the interleaving loop if data permutation is not 
-                      allowed.  */
-                   if  (DR_GROUP_FIRST_DR (vinfo_for_stmt (stmt)) != stmt) 
+                      the interleaving loop if data permutation is not allowed.
+                      Check that there is no gap between the loads.  */
+                   if (DR_GROUP_FIRST_DR (vinfo_for_stmt (stmt)) != stmt
+                        || DR_GROUP_GAP (vinfo_for_stmt (stmt)) != 0) 
                      {
-                       /* FORNOW: data permutations are not supported.  */
+                       /* FORNOW: data permutations and gaps in loads are not 
+                           supported.  */
                        if (vect_print_dump_info (REPORT_SLP)) 
                          {
                            fprintf (vect_dump, "Build SLP failed: strided "
-                                    " loads need permutation ");
+                                    " loads need permutation or have gaps ");
                            print_generic_expr (vect_dump, stmt, TDF_SLIM);
                          }
 
@@ -2811,13 +2819,17 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, slp_tree *node,
                  }
                else
                  {
-                   if (DR_GROUP_NEXT_DR (vinfo_for_stmt (prev_stmt)) != stmt)
+                    /* Check that we have consecutive loads from interleaving
+                       chain and that there is no gap between the loads.  */
+                   if (DR_GROUP_NEXT_DR (vinfo_for_stmt (prev_stmt)) != stmt
+                        || DR_GROUP_GAP (vinfo_for_stmt (stmt)) != 1)
                      {
-                       /* FORNOW: data permutations are not supported.  */
+                       /* FORNOW: data permutations and gaps in loads are not
+                           supported.  */
                        if (vect_print_dump_info (REPORT_SLP)) 
                          {
                            fprintf (vect_dump, "Build SLP failed: strided "
-                                    " loads need permutation ");
+                                    " loads need permutation or have gaps ");
                            print_generic_expr (vect_dump, stmt, TDF_SLIM);
                          }
                        return false;