]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/69882 (Excessive reduction statements generated by SLP)
authorRichard Biener <rguenther@suse.de>
Mon, 22 Feb 2016 14:53:17 +0000 (14:53 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 22 Feb 2016 14:53:17 +0000 (14:53 +0000)
2016-02-22  Richard Biener  <rguenther@suse.de>

PR tree-optimization/69882
* tree-vect-slp.c (vect_attempt_slp_rearrange_stmts): Properly
preserve permutations present because of gaps.
(vect_supported_load_permutation_p): Always continue checking
permutations after vect_attempt_slp_rearrange_stmts.

* gfortran.dg/vect/pr69882.f90: New testcase.

From-SVN: r233605

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/vect/pr69882.f90 [new file with mode: 0644]
gcc/tree-vect-slp.c

index 83c6a67f7b9cc1a715783d72411236f2bdcaa26b..a352259a2a0ee4b5f1e6165bfe82e90589d46772 100644 (file)
@@ -1,3 +1,11 @@
+2016-02-22  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/69882
+       * tree-vect-slp.c (vect_attempt_slp_rearrange_stmts): Properly
+       preserve permutations present because of gaps.
+       (vect_supported_load_permutation_p): Always continue checking
+       permutations after vect_attempt_slp_rearrange_stmts.
+
 2016-02-22  Bin Cheng  <bin.cheng@arm.com>
 
        * tree-vect-loop.c (vect_estimate_min_profitable_iters): Dump
index 0b82dae0a03d62fb06d63b4d70c256008ee68502..02a3b3ec441d5ad6fb6fcdc6d287988136466c6d 100644 (file)
@@ -1,3 +1,8 @@
+2016-02-22  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/69882
+       * gfortran.dg/vect/pr69882.f90: New testcase.
+
 2016-02-22  Jakub Jelinek  <jakub@redhat.com>
 
        PR target/69885
diff --git a/gcc/testsuite/gfortran.dg/vect/pr69882.f90 b/gcc/testsuite/gfortran.dg/vect/pr69882.f90
new file mode 100644 (file)
index 0000000..f77e33f
--- /dev/null
@@ -0,0 +1,41 @@
+! { dg-additional-options "-Ofast" }
+! { dg-additional-options "-mavx" { target avx_runtime } }
+
+subroutine foo(a, x)
+  implicit none
+
+  integer, parameter :: XX=4, YY=26
+  integer, intent(in) :: x
+  real *8, intent(in) :: a(XX,YY)
+  real *8 :: c(XX)
+
+  integer i, k
+
+  c = 0
+
+  do k=x,YY
+     do i=1,2
+        c(i) = max(c(i), a(i,k))
+     end do
+  end do
+
+  PRINT *, "c=", c
+
+  IF (c(1) .gt. 0.0) THEN
+     CALL ABORT
+  END IF
+
+  IF (c(2) .gt. 0.0) THEN
+     CALL ABORT
+  END IF
+end subroutine foo
+
+PROGRAM MAIN
+  real *8 a(4, 26)
+
+  a = 0
+  a(3,1) = 100.0
+  a(4,1) = 100.0
+  
+  CALL FOO(a, 1)
+END PROGRAM
index 660b14c417d68fa26c4aff728bceb435482da031..988ec10e1da4d9cbcf89dabcae65291f4579ad47 100644 (file)
@@ -1332,8 +1332,19 @@ vect_attempt_slp_rearrange_stmts (slp_instance slp_instn)
                            node->load_permutation);
 
   /* We are done, no actual permutations need to be generated.  */
+  unsigned int unrolling_factor = SLP_INSTANCE_UNROLLING_FACTOR (slp_instn);
   FOR_EACH_VEC_ELT (SLP_INSTANCE_LOADS (slp_instn), i, node)
-    SLP_TREE_LOAD_PERMUTATION (node).release ();
+    {
+      gimple *first_stmt = SLP_TREE_SCALAR_STMTS (node)[0];
+      first_stmt = GROUP_FIRST_ELEMENT (vinfo_for_stmt (first_stmt));
+      /* But we have to keep those permutations that are required because
+         of handling of gaps.  */
+      if (unrolling_factor == 1
+         || (group_size == GROUP_SIZE (vinfo_for_stmt (first_stmt))
+             && GROUP_GAP (vinfo_for_stmt (first_stmt)) == 0))
+       SLP_TREE_LOAD_PERMUTATION (node).release ();
+    }
+
   return true;
 }
 
@@ -1381,12 +1392,7 @@ vect_supported_load_permutation_p (slp_instance slp_instn)
      In reduction chain the order of the loads is not important.  */
   if (!STMT_VINFO_DATA_REF (vinfo_for_stmt (stmt))
       && !GROUP_FIRST_ELEMENT (vinfo_for_stmt (stmt)))
-    {
-      if (vect_attempt_slp_rearrange_stmts (slp_instn))
-       return true;
-
-      /* Fallthru to general load permutation handling.  */
-    }
+    vect_attempt_slp_rearrange_stmts (slp_instn);
 
   /* In basic block vectorization we allow any subchain of an interleaving
      chain.