]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: [multiple changes]
authorRichard Biener <rguenther@suse.de>
Wed, 25 Feb 2015 10:28:01 +0000 (10:28 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 25 Feb 2015 10:28:01 +0000 (10:28 +0000)
2015-02-25  Richard Biener  <rguenther@suse.de>

Backport from mainline
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: r220960

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr63593.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/pr65063.c [new file with mode: 0644]
gcc/tree-predcom.c

index 6ee0c856eecd483084dbcb1f092a5399f4285ca6..2319ab8b91b0eb45ea5884d062b42f0453c10cfd 100644 (file)
@@ -1,3 +1,19 @@
+2015-02-25  Richard Biener  <rguenther@suse.de>
+
+       Backport from mainline
+       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-24  Richard Biener  <rguenther@suse.de>
 
        Backport from mainline
index 2dfe1002ea52151553e1aed7fe855b0e23784aed..a83392918e1a53ff2b3ff89e07f9efa95d56d81d 100644 (file)
@@ -1,3 +1,16 @@
+2015-02-25  Richard Biener  <rguenther@suse.de>
+
+       Backport from mainline
+       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-24  Richard Biener  <rguenther@suse.de>
 
        Backport from mainline
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;
+}
index 73a7a26c9ddbb1deaa4ffe42daed563ffc9c85f2..4bc85e46df875e8f639c0a9cd8a22211941fa6c5 100644 (file)
@@ -1666,9 +1666,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
     {
@@ -1697,9 +1696,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;
@@ -1732,6 +1743,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);
 }