]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: [multiple changes]
authorRichard Biener <rguenther@suse.de>
Tue, 26 Mar 2019 11:18:26 +0000 (11:18 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 26 Mar 2019 11:18:26 +0000 (11:18 +0000)
2019-03-26  Richard Biener  <rguenther@suse.de>

Backport from mainline
2019-01-08  Richard Biener  <rguenther@suse.de>

PR tree-optimization/86554
* tree-ssa-sccvn.c (visit_nary_op): When value-numbering to
expressions with different overflow behavior make sure there's an
available expression on the path.

* gcc.dg/torture/pr86554-1.c: New testcase.
* gcc.dg/torture/pr86554-2.c: Likewise.

2018-11-20  Richard Biener  <rguenther@suse.de>

PR tree-optimization/88105
* tree-ssa-dom.c (pass_dominator::execute): Do not walk
backedges.

* gcc.dg/gomp/pr88105.c: New testcase.

2018-03-08  Richard Biener  <rguenther@suse.de>

PR middle-end/84552
* tree-scalar-evolution.c: Include tree-into-ssa.h.
(follow_copies_to_constant): Do not follow SSA names registered
for update.

* gcc.dg/graphite/pr84552.c: New testcase.

From-SVN: r269939

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/gomp/pr88105.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/graphite/pr84552.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/pr86554-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/pr86554-2.c [new file with mode: 0644]
gcc/tree-scalar-evolution.c
gcc/tree-ssa-dom.c
gcc/tree-ssa-sccvn.c

index 238bdbd251164147afd8eeff559c0aafaeea5b35..58cd084a47d923d74c0248c3fb538ead4a78d2b4 100644 (file)
@@ -1,3 +1,26 @@
+2019-03-26  Richard Biener  <rguenther@suse.de>
+
+       Backport from mainline
+       2019-01-08  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/86554
+       * tree-ssa-sccvn.c (visit_nary_op): When value-numbering to
+       expressions with different overflow behavior make sure there's an
+       available expression on the path.
+
+       2018-11-20  Richard Biener  <rguenther@suse.de>
+       PR tree-optimization/88105
+       * tree-ssa-dom.c (pass_dominator::execute): Do not walk
+       backedges.
+
+       2018-03-08  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/84552
+       * tree-scalar-evolution.c: Include tree-into-ssa.h.
+       (follow_copies_to_constant): Do not follow SSA names registered
+       for update.
+
 2019-03-21  Bill Schmidt  <wschmidt@linux.ibm.com>
 
         * config/rs6000/rs6000.c (rs6000_analyze_swaps): Rebuild
index 4ca1066d91a96c432f6aea48bf0344424feef55f..242c721bc982720fcdd8dba0a3b29617329fce6a 100644 (file)
@@ -1,3 +1,22 @@
+2019-03-26  Richard Biener  <rguenther@suse.de>
+
+       Backport from mainline
+       2019-01-08  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/86554
+       * gcc.dg/torture/pr86554-1.c: New testcase.
+       * gcc.dg/torture/pr86554-2.c: Likewise.
+
+       2018-11-20  Richard Biener  <rguenther@suse.de>
+       PR tree-optimization/88105
+       * gcc.dg/gomp/pr88105.c: New testcase.
+
+       2018-03-08  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/84552
+       * gcc.dg/graphite/pr84552.c: New testcase.
+
 2019-03-25  Janus Weil  <janus@gcc.gnu.org>
 
        PR fortran/71861
diff --git a/gcc/testsuite/gcc.dg/gomp/pr88105.c b/gcc/testsuite/gcc.dg/gomp/pr88105.c
new file mode 100644 (file)
index 0000000..9680fdd
--- /dev/null
@@ -0,0 +1,30 @@
+/* { dg-do compile } */
+/* { dg-options "-fopenmp -O -fexceptions -fnon-call-exceptions -fno-tree-fre" } */
+
+int
+s0 (void)
+{
+  int g6, oh = 0;
+  int *a6 = &g6;
+
+  (void) a6;
+
+#pragma omp parallel for
+  for (g6 = 0; g6 < 1; ++g6)
+    {
+      int zk;
+
+      for (zk = 0; zk < 1; ++zk)
+        {
+          oh += zk / (zk + 1);
+
+          for (;;)
+            {
+            }
+        }
+
+      a6 = &zk;
+    }
+
+  return oh;
+}
diff --git a/gcc/testsuite/gcc.dg/graphite/pr84552.c b/gcc/testsuite/gcc.dg/graphite/pr84552.c
new file mode 100644 (file)
index 0000000..15cbb08
--- /dev/null
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -floop-nest-optimize -fno-tree-copy-prop -fno-tree-fre -fno-tree-loop-ivcanon" } */
+
+int cx;
+
+int
+e6 (int pj, int xe)
+{
+  for (cx = 0; cx < 2; ++cx)
+    while (xe < 1)
+      {
+       for (cx = 0; cx < 2; ++cx)
+         pj *= 2;
+
+       if (cx != 0)
+         goto o3;
+
+       ++xe;
+      }
+
+o3:
+  return pj;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr86554-1.c b/gcc/testsuite/gcc.dg/torture/pr86554-1.c
new file mode 100644 (file)
index 0000000..64f851e
--- /dev/null
@@ -0,0 +1,35 @@
+/* { dg-do run } */
+
+struct foo
+{
+  unsigned x;
+};
+typedef struct foo foo;
+
+static inline int zot(foo *f)
+{
+  int ret;
+
+  if (f->x > 0x7FFFFFFF)
+    ret = (int)(f->x - 0x7FFFFFFF);
+  else
+    ret = (int)f->x - 0x7FFFFFFF;
+  return ret;
+}
+
+void __attribute__((noinline,noclone)) bar(foo *f)
+{
+  int ret = zot(f);
+  volatile int x = ret;
+  if (ret < 1)
+    __builtin_abort ();
+}
+
+int main()
+{
+  foo f;
+  f.x = 0x800003f8;
+
+  bar(&f);
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr86554-2.c b/gcc/testsuite/gcc.dg/torture/pr86554-2.c
new file mode 100644 (file)
index 0000000..9e57a9c
--- /dev/null
@@ -0,0 +1,49 @@
+/* { dg-do run } */
+/* { dg-require-effective-target int32plus } */
+
+struct s { __INT64_TYPE__ e; };
+
+static void f (struct s *ps)
+{
+  volatile __INT64_TYPE__ m = 9223372036854775807;
+  const char *str = "11E";
+  int r;
+  __INT64_TYPE__ sum;
+
+  ps->e = 0;
+
+  for (;;)
+    {
+      if (*str++ != '1')
+       break;
+      ps->e ++;
+    }
+
+  r = 1;
+  sum = m;
+
+  if (sum >= 0 && ps->e >= 0)
+    {
+      __UINT64_TYPE__ uc;
+      uc = (__UINT64_TYPE__) sum + (__UINT64_TYPE__) ps->e;
+      if (uc > 9223372036854775807)
+       r = 2;
+      else
+       sum = 17;
+    }
+  else
+    sum = sum + ps->e;
+
+  if (sum != 9223372036854775807)
+    __builtin_abort ();
+  if (r != 2)
+    __builtin_abort ();
+  ps->e = sum;
+}
+
+int main (void)
+{
+  struct s s;
+  f (&s);
+  return 0;
+}
index cbd17e8644fe4e488c28e63231f4f93e523646d7..790050a20c9ba2d52aa1c6ab61afe31b065a8498 100644 (file)
@@ -280,6 +280,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "params.h"
 #include "tree-ssa-propagate.h"
 #include "gimple-fold.h"
+#include "tree-into-ssa.h"
 
 static tree analyze_scalar_evolution_1 (struct loop *, tree, tree);
 static tree analyze_scalar_evolution_for_address_of (struct loop *loop,
@@ -1532,7 +1533,10 @@ static tree
 follow_copies_to_constant (tree var)
 {
   tree res = var;
-  while (TREE_CODE (res) == SSA_NAME)
+  while (TREE_CODE (res) == SSA_NAME
+        /* We face not updated SSA form in multiple places and this walk
+           may end up in sibling loops so we have to guard it.  */
+        && !name_registered_for_update_p (res))
     {
       gimple *def = SSA_NAME_DEF_STMT (res);
       if (gphi *phi = dyn_cast <gphi *> (def))
index 22ac57e1f75a520c282a30af3ee89472c3c01b76..10e4ec705a65ce67d33ad4ccd501a8804fcfedd6 100644 (file)
@@ -531,7 +531,8 @@ pass_dominator::execute (function *fun)
          if (bb == NULL)
            continue;
          while (single_succ_p (bb)
-                && (single_succ_edge (bb)->flags & EDGE_EH) == 0)
+                && (single_succ_edge (bb)->flags
+                    & (EDGE_EH|EDGE_DFS_BACK)) == 0)
            bb = single_succ (bb);
          if (bb == EXIT_BLOCK_PTR_FOR_FN (fun))
            continue;
index 8e7052f950ecdcc35a88ca97f5cf6980a2c0f075..c93f1f2619591cee775926e831183b3b7ab72124 100644 (file)
@@ -3572,7 +3572,17 @@ visit_nary_op (tree lhs, gassign *stmt)
                  ops[0] = vn_nary_op_lookup_pieces
                      (2, gimple_assign_rhs_code (def), type, ops, NULL);
                  /* We have wider operation available.  */
-                 if (ops[0])
+                 if (ops[0]
+                     /* If the leader is a wrapping operation we can
+                        insert it for code hoisting w/o introducing
+                        undefined overflow.  If it is not it has to
+                        be available.  See PR86554.  */
+                     && (TYPE_OVERFLOW_WRAPS (TREE_TYPE (ops[0]))
+                         || TREE_CODE (ops[0]) != SSA_NAME
+                         || SSA_NAME_IS_DEFAULT_DEF (ops[0])
+                         || dominated_by_p_w_unex
+                              (gimple_bb (stmt),
+                               gimple_bb (SSA_NAME_DEF_STMT (ops[0])))))
                    {
                      unsigned lhs_prec = TYPE_PRECISION (type);
                      unsigned rhs_prec = TYPE_PRECISION (TREE_TYPE (rhs1));