]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Backport PRs 63593, 64373, 64530, 65063
authorRichard Biener <rguenth@gcc.gnu.org>
Fri, 20 Feb 2015 07:32:08 +0000 (07:32 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 20 Feb 2015 07:32:08 +0000 (07:32 +0000)
2015-02-20  Richard Biener  <rguenther@suse.de>

Backport from mainline
2015-01-12  Richard Biener  <rguenther@suse.de>

PR tree-optimization/64530
* tree-loop-distribution.c (pg_add_dependence_edges): Shuffle
back dr1.

* gfortran.dg/pr64530.f90: New testcase.

2015-02-13  Richard Biener  <rguenther@suse.de>

PR lto/64373
* lto-streamer-out.c (tree_is_indexable): Guard for NULL
DECL_CONTEXT.

* gcc.dg/lto/pr64373_0.c: New testcase.

2015-02-16  Richard Biener  <rguenther@suse.de>

PR tree-optimization/63593
* tree-predcom.c (execute_pred_commoning_chain): Delay removing
stmts and releasing SSA names until...
(execute_pred_commoning): ... after processing all chains.

* gcc.dg/pr63593.c: New testcase.

2015-02-18  Richard Biener  <rguenther@suse.de>

PR tree-optimization/65063
* tree-predcom.c (determine_unroll_factor): Return 1 if we
have replaced looparound PHIs.

* gcc.dg/pr65063.c: New testcase.

From-SVN: r220835

gcc/ChangeLog
gcc/lto-streamer-out.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/lto/pr64373_0.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/pr63593.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/pr65063.c [new file with mode: 0644]
gcc/testsuite/gfortran.dg/pr64530.f90 [new file with mode: 0644]
gcc/tree-loop-distribution.c
gcc/tree-predcom.c

index ca756c994fd16cf39ae60b145abf0d7ae788f967..170f1f3c72d31580c3e9df871179832c63d3221d 100644 (file)
@@ -1,3 +1,33 @@
+2015-02-20  Richard Biener  <rguenther@suse.de>
+
+       Backport from mainline
+       2015-01-12  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/64530
+       * tree-loop-distribution.c (pg_add_dependence_edges): Shuffle
+       back dr1.
+
+       2015-02-13  Richard Biener  <rguenther@suse.de>
+
+       PR lto/64373
+       * lto-streamer-out.c (tree_is_indexable): Guard for NULL
+       DECL_CONTEXT.
+
+       2015-02-16  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/63593
+       * tree-predcom.c (execute_pred_commoning_chain): Delay removing
+       stmts and releasing SSA names until...
+       (execute_pred_commoning): ... after processing all chains.
+
+       2015-02-18  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/65063
+       * tree-predcom.c (determine_unroll_factor): Return 1 if we
+       have replaced looparound PHIs.
+
+2015-02-19  John David Anglin  <danlgin@gcc.gnu.org>
+
        * config/pa/pa.c (pa_reloc_rw_mask): New function.
        (TARGET_ASM_RELOC_RW_MASK): Define.
        (pa_cannot_force_const_mem): Revert previous change.
index 6b5df1a611ceb1b20a04ab4b8c855564d109f607..4cf6bdafc3cd11d511a33c0c21beddf06d31c7d6 100644 (file)
@@ -135,7 +135,8 @@ tree_is_indexable (tree t)
   /* Parameters and return values of functions of variably modified types
      must go to global stream, because they may be used in the type
      definition.  */
-  if (TREE_CODE (t) == PARM_DECL || TREE_CODE (t) == RESULT_DECL)
+  if ((TREE_CODE (t) == PARM_DECL || TREE_CODE (t) == RESULT_DECL)
+      && DECL_CONTEXT (t))
     return variably_modified_type_p (TREE_TYPE (DECL_CONTEXT (t)), NULL_TREE);
   else if (((TREE_CODE (t) == VAR_DECL && !TREE_STATIC (t))
            || TREE_CODE (t) == TYPE_DECL
index 8615487aeb8217a023929818a9e9f28a24f23dc8..f66dbc0c7c01e4b41e89f58db7c2f09132bc20aa 100644 (file)
@@ -1,3 +1,26 @@
+2015-02-20  Richard Biener  <rguenther@suse.de>
+
+       Backport from mainline
+       2015-01-12  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/64530
+       * gfortran.dg/pr64530.f90: New testcase.
+
+       2015-02-13  Richard Biener  <rguenther@suse.de>
+
+       PR lto/64373
+       * gcc.dg/lto/pr64373_0.c: New testcase.
+
+       2015-02-16  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/63593
+       * gcc.dg/pr63593.c: New testcase.
+
+       2015-02-18  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/65063
+       * gcc.dg/pr65063.c: New testcase.
+
 2015-02-19  Richard Biener  <rguenther@suse.de>
 
        Backport from mainline
diff --git a/gcc/testsuite/gcc.dg/lto/pr64373_0.c b/gcc/testsuite/gcc.dg/lto/pr64373_0.c
new file mode 100644 (file)
index 0000000..b4f3fdf
--- /dev/null
@@ -0,0 +1,10 @@
+/* { dg-lto-do assemble } */
+
+extern void b(int L, float (*data)[L]);
+
+void a(void)
+{
+  float* p = 0;
+  int i = 0;
+  b(10, (float (*)[10])(p + i));
+}
diff --git a/gcc/testsuite/gcc.dg/pr63593.c b/gcc/testsuite/gcc.dg/pr63593.c
new file mode 100644 (file)
index 0000000..08bc8f9
--- /dev/null
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -fno-tree-vectorize" } */
+
+int in[2 * 4][4];
+int out[4];
+
+void
+foo (void)
+{
+  int sum;
+  int i, j, k;
+  for (k = 0; k < 4; k++)
+    {
+      sum = 1;
+      for (j = 0; j < 4; j++)
+       for (i = 0; i < 4; i++)
+         sum *= in[i + k][j];
+      out[k] = sum;
+    }
+}
diff --git a/gcc/testsuite/gcc.dg/pr65063.c b/gcc/testsuite/gcc.dg/pr65063.c
new file mode 100644 (file)
index 0000000..bcbdbf0
--- /dev/null
@@ -0,0 +1,33 @@
+/* { dg-do run } */
+/* { dg-options "-O3 -fno-tree-loop-ivcanon -fno-tree-vectorize" } */
+
+static int in[8][4];
+static int out[4];
+static const int check_result[] = {0, 16, 256, 4096};
+
+static inline void foo ()
+{
+  int sum;
+  int i, j, k;
+  for (k = 0; k < 4; k++)
+    {
+      sum = 1;
+      for (j = 0; j < 4; j++)
+       for (i = 0; i < 4; i++)
+         sum *= in[i + k][j];
+      out[k] = sum;
+    }
+}
+
+int main ()
+{
+  int i, j, k;
+  for (i = 0; i < 8; i++)
+    for (j = 0; j < 4; j++)
+      in[i][j] = (i + 2) / 3;
+  foo ();
+  for (k = 0; k < 4; k++)
+    if (out[k] != check_result[k])
+      __builtin_abort ();
+  return 0;
+}
diff --git a/gcc/testsuite/gfortran.dg/pr64530.f90 b/gcc/testsuite/gfortran.dg/pr64530.f90
new file mode 100644 (file)
index 0000000..9805f62
--- /dev/null
@@ -0,0 +1,38 @@
+! { dg-do run }
+
+program bug
+  ! Bug triggered with at least three elements
+  integer, parameter :: asize = 3
+
+  double precision,save :: ave(asize)
+  double precision,save :: old(asize)
+  double precision,save :: tmp(asize)
+
+  ave(:) = 10.d0
+  old(:) = 3.d0
+  tmp(:) = 0.d0
+
+  call buggy(2.d0,asize,ave,old,tmp)
+  if (any (tmp(:) .ne. 3.5)) call abort
+end
+
+subroutine buggy(scale_factor, asize, ave, old, tmp)
+
+  implicit none
+  ! Args
+  double precision scale_factor
+  integer asize
+  double precision ave(asize)
+  double precision old(asize)
+  double precision tmp(asize)
+
+  ! Local 
+  integer i
+
+  do i = 1, asize
+    tmp(i) = ave(i) - old(i)
+    old(i) = ave(i)
+    tmp(i) = tmp(i) / scale_factor
+  end do
+
+end subroutine buggy
index 9db92dbf9bfd72c2ad9cec4757c5e32ec224ae77..892de148de29d4f674c88236b4a684a54b6666a6 100644 (file)
@@ -1342,6 +1342,7 @@ pg_add_dependence_edges (struct graph *rdg, vec<loop_p> loops, int dir,
   for (int ii = 0; drs1.iterate (ii, &dr1); ++ii)
     for (int jj = 0; drs2.iterate (jj, &dr2); ++jj)
       {
+       data_reference_p saved_dr1 = dr1;
        int this_dir = 1;
        ddr_p ddr;
        /* Re-shuffle data-refs to be in dominator order.  */
@@ -1387,6 +1388,8 @@ pg_add_dependence_edges (struct graph *rdg, vec<loop_p> loops, int dir,
          dir = this_dir;
        else if (dir != this_dir)
          return 2;
+       /* Shuffle "back" dr1.  */
+       dr1 = saved_dr1;
       }
   return dir;
 }
index 20b0e3b0ab8f9693b310d0d8a55f16bc417d69da..8f2413d4423f31766fc7d21fd299d3780fee1ef4 100644 (file)
@@ -1715,9 +1715,8 @@ execute_pred_commoning_chain (struct loop *loop, chain_p chain,
   if (chain->combined)
     {
       /* For combined chains, just remove the statements that are used to
-        compute the values of the expression (except for the root one).  */
-      for (i = 1; chain->refs.iterate (i, &a); i++)
-       remove_stmt (a->stmt);
+        compute the values of the expression (except for the root one).
+        We delay this until after all chains are processed.  */
     }
   else
     {
@@ -1746,9 +1745,21 @@ determine_unroll_factor (vec<chain_p> chains)
 
   FOR_EACH_VEC_ELT (chains, i, chain)
     {
-      if (chain->type == CT_INVARIANT || chain->combined)
+      if (chain->type == CT_INVARIANT)
        continue;
 
+      if (chain->combined)
+       {
+         /* For combined chains, we can't handle unrolling if we replace
+            looparound PHIs.  */
+         dref a;
+         unsigned j;
+         for (j = 1; chain->refs.iterate (j, &a); j++)
+           if (gimple_code (a->stmt) == GIMPLE_PHI)
+             return 1;
+         continue;
+       }
+
       /* The best unroll factor for this chain is equal to the number of
         temporary variables that we create for it.  */
       af = chain->length;
@@ -1781,6 +1792,21 @@ execute_pred_commoning (struct loop *loop, vec<chain_p> chains,
        execute_pred_commoning_chain (loop, chain, tmp_vars);
     }
 
+  FOR_EACH_VEC_ELT (chains, i, chain)
+    {
+      if (chain->type == CT_INVARIANT)
+       ;
+      else if (chain->combined)
+       {
+         /* For combined chains, just remove the statements that are used to
+            compute the values of the expression (except for the root one).  */
+         dref a;
+         unsigned j;
+         for (j = 1; chain->refs.iterate (j, &a); j++)
+           remove_stmt (a->stmt);
+       }
+    }
+
   update_ssa (TODO_update_ssa_only_virtuals);
 }