]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR tree-optimization/79411 (ICE: SSA corruption (fail_abnormal_edge_coal...
authorJakub Jelinek <jakub@redhat.com>
Tue, 30 May 2017 07:58:01 +0000 (09:58 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 30 May 2017 07:58:01 +0000 (09:58 +0200)
Backported from mainline
2017-02-10  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/79411
* tree-ssa-reassoc.c (is_reassociable_op): Return false if
stmt operands are SSA_NAMEs used in abnormal phis.
(can_reassociate_p): Return false if op is SSA_NAME used in abnormal
phis.

* gcc.c-torture/compile/pr79411.c: New test.

From-SVN: r248642

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr79411.c [new file with mode: 0644]
gcc/tree-ssa-reassoc.c

index 5d4bf121eda1509e8276f7acb66fcd68220d2384..a776f6fc28ef1667158140bf4a0807fb9d3dbed8 100644 (file)
@@ -1,6 +1,14 @@
 2017-05-30  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2017-02-10  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/79411
+       * tree-ssa-reassoc.c (is_reassociable_op): Return false if
+       stmt operands are SSA_NAMEs used in abnormal phis.
+       (can_reassociate_p): Return false if op is SSA_NAME used in abnormal
+       phis.
+
        2017-02-07  Jakub Jelinek  <jakub@redhat.com>
                    Richard Biener  <rguenther@suse.de>
 
index 92bbd88b19d9f1e18bdbe8836e10f402f641fc88..59ad05e71a6b0dd3dcf5e89909adef8a372bc577 100644 (file)
@@ -1,6 +1,11 @@
 2017-05-30  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2017-02-10  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/79411
+       * gcc.c-torture/compile/pr79411.c: New test.
+
        2017-02-02  Jakub Jelinek  <jakub@redhat.com>
 
        PR target/79197
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr79411.c b/gcc/testsuite/gcc.c-torture/compile/pr79411.c
new file mode 100644 (file)
index 0000000..7bd545b
--- /dev/null
@@ -0,0 +1,22 @@
+/* PR tree-optimization/79411 */
+
+typedef struct __jmp_buf_tag { char buf[1024]; } jmp_buf[1];
+extern int setjmp (jmp_buf);
+extern int bar (unsigned int *);
+extern jmp_buf *baz (void);
+struct C { int c1; unsigned int c2, c3, c4; };
+
+void
+foo (struct C *x, const int *y, unsigned int *z, unsigned int e, unsigned int g)
+{
+  unsigned int d = 0;
+  unsigned long f;
+  setjmp (*baz ());
+  f = 1 + d;
+  if ((x->c1 || x->c2) && g && (!e || d >= 8))
+    d = 16;
+  else
+    d = 8;
+  if ((!x->c3 && !x->c4 || *y == 0) && !e && bar (z))
+    *z = 1 + f;
+}
index 0710bae7de028360027a8a2aec397aaf01e96252..29cfdee271ce4bc1c9c9cd691107ef10e53ad432 100644 (file)
@@ -663,7 +663,18 @@ is_reassociable_op (gimple stmt, enum tree_code code, struct loop *loop)
   if (is_gimple_assign (stmt)
       && gimple_assign_rhs_code (stmt) == code
       && has_single_use (gimple_assign_lhs (stmt)))
-    return true;
+    {
+      tree rhs1 = gimple_assign_rhs1 (stmt);
+      tree rhs2 = gimple_assign_rhs1 (stmt);
+      if (TREE_CODE (rhs1) == SSA_NAME
+         && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (rhs1))
+       return false;
+      if (rhs2
+         && TREE_CODE (rhs2) == SSA_NAME
+         && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (rhs2))
+       return false;
+      return true;
+    }
 
   return false;
 }
@@ -4342,6 +4353,8 @@ static bool
 can_reassociate_p (tree op)
 {
   tree type = TREE_TYPE (op);
+  if (TREE_CODE (op) == SSA_NAME && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (op))
+    return false;
   if ((INTEGRAL_TYPE_P (type) && TYPE_OVERFLOW_WRAPS (type))
       || NON_SAT_FIXED_POINT_TYPE_P (type)
       || (flag_associative_math && FLOAT_TYPE_P (type)))