[tail-merge] Don't merge bbs with bb_has_abnormal_pred
authorTom de Vries <tom@codesourcery.com>
Thu, 22 Mar 2018 10:21:12 +0000 (10:21 +0000)
committerTom de Vries <vries@gcc.gnu.org>
Thu, 22 Mar 2018 10:21:12 +0000 (10:21 +0000)
2018-03-22  Tom de Vries  <tom@codesourcery.com>

PR tree-optimization/84956
* tree-ssa-tail-merge.c (find_clusters_1): Skip bbs with
bb_has_abnormal_pred.

* gcc.dg/pr84956.c: New test.

From-SVN: r258758

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr84956.c [new file with mode: 0644]
gcc/tree-ssa-tail-merge.c

index 869caa2fe6d5d5487f3c8262aaf01d5860997b2c..06320e4c802c211c5400e901d1e51d2776f30e30 100644 (file)
@@ -1,3 +1,9 @@
+2018-03-22  Tom de Vries  <tom@codesourcery.com>
+
+       PR tree-optimization/84956
+       * tree-ssa-tail-merge.c (find_clusters_1): Skip bbs with
+       bb_has_abnormal_pred.
+
 2018-03-22  Jakub Jelinek  <jakub@redhat.com>
 
        PR sanitizer/85018
index 00b804c701893c07153f7d2231f43e162004d1d1..abc1b9fb76accfce911ca26def6421026d494e3b 100644 (file)
@@ -1,3 +1,8 @@
+2018-03-22  Tom de Vries  <tom@codesourcery.com>
+
+       PR tree-optimization/84956
+       * gcc.dg/pr84956.c: New test.
+
 2018-03-22  Marek Polacek  <polacek@redhat.com>
 
        PR c++/84854
diff --git a/gcc/testsuite/gcc.dg/pr84956.c b/gcc/testsuite/gcc.dg/pr84956.c
new file mode 100644 (file)
index 0000000..055a749
--- /dev/null
@@ -0,0 +1,27 @@
+/* { dg-options "-O2 -ftree-tail-merge" } */
+
+char a;
+int c;
+unsigned b ();
+
+unsigned
+setjmp ()
+{
+}
+
+static void
+d ()
+{
+  if (b ())
+    c = 3;
+}
+
+void
+e ()
+{
+  d ();
+  a && ({ setjmp (); });
+  a && ({ setjmp (); });
+  a && ({ setjmp (); });
+}
+
index a687c3f28df9ea2212221029259b8f6e2b82ad69..f482ce197cd8e0b1ad9b1bd995c2d1d33ff21256 100644 (file)
@@ -1455,7 +1455,8 @@ find_clusters_1 (same_succ *same_succ)
       /* TODO: handle blocks with phi-nodes.  We'll have to find corresponding
         phi-nodes in bb1 and bb2, with the same alternatives for the same
         preds.  */
-      if (bb_has_non_vop_phi (bb1) || bb_has_eh_pred (bb1))
+      if (bb_has_non_vop_phi (bb1) || bb_has_eh_pred (bb1)
+         || bb_has_abnormal_pred (bb1))
        continue;
 
       nr_comparisons = 0;
@@ -1463,7 +1464,8 @@ find_clusters_1 (same_succ *same_succ)
        {
          bb2 = BASIC_BLOCK_FOR_FN (cfun, j);
 
-         if (bb_has_non_vop_phi (bb2) || bb_has_eh_pred (bb2))
+         if (bb_has_non_vop_phi (bb2) || bb_has_eh_pred (bb2)
+             || bb_has_abnormal_pred (bb2))
            continue;
 
          if (BB_CLUSTER (bb1) != NULL && BB_CLUSTER (bb1) == BB_CLUSTER (bb2))