Fix bit-test expansion for single cluster (PR tree-optimization/86263).
authorMartin Liska <mliska@suse.cz>
Fri, 29 Jun 2018 10:57:00 +0000 (12:57 +0200)
committerMartin Liska <marxin@gcc.gnu.org>
Fri, 29 Jun 2018 10:57:00 +0000 (10:57 +0000)
2018-06-29  Martin Liska  <mliska@suse.cz>

        PR tree-optimization/86263
* tree-switch-conversion.c (switch_decision_tree::try_switch_expansion):
        Make edge redirection.
2018-06-29  Martin Liska  <mliska@suse.cz>

        PR tree-optimization/86263
* gcc.dg/tree-ssa/pr86263.c: New test.

From-SVN: r262247

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/pr86263.c [new file with mode: 0644]
gcc/tree-switch-conversion.c

index 5c7c502212322b5c1af618ac52fd1f039220c266..44012454e27a8f41e17074406ebf4c42bbec00b4 100644 (file)
@@ -1,3 +1,9 @@
+2018-06-29  Martin Liska  <mliska@suse.cz>
+
+        PR tree-optimization/86263
+       * tree-switch-conversion.c (switch_decision_tree::try_switch_expansion):
+        Make edge redirection.
+
 2018-06-29  David Malcolm  <dmalcolm@redhat.com>
 
        * dumpfile.c (dump_loc): Add indentation based on scope depth.
index 58860c7aebd12af739f72fa286ad955c45636b83..a9f7fd96662c1adc0041308babc2c8f92222ff64 100644 (file)
@@ -1,3 +1,8 @@
+2018-06-29  Martin Liska  <mliska@suse.cz>
+
+        PR tree-optimization/86263
+       * gcc.dg/tree-ssa/pr86263.c: New test.
+
 2018-06-28  Carl Love  <cel@us.ibm.com>
 
        * gcc.target/p9-extract-1.c: Add test case.
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr86263.c b/gcc/testsuite/gcc.dg/tree-ssa/pr86263.c
new file mode 100644 (file)
index 0000000..7f80c22
--- /dev/null
@@ -0,0 +1,29 @@
+/* { dg-do compile } */
+
+void f1 (void *);
+void f2 (void *);
+void f3 (void *);
+void f4 (void *);
+
+char
+_dcvt (void *ptr, char type, int opt, int val)
+{
+  switch (type)
+    {
+    case 'f':
+      f4 (ptr);
+    case 'F':
+      f1 (ptr);
+      break;
+    case 'g':
+    case 'G':
+      if (opt == 0)
+       opt = 1;
+      f2 (ptr);
+      break;
+    case 'e':
+    case 'E':
+      f3 (ptr);
+    }
+  return val;
+}
index b79f2fdb6e659eb527d0415ce6ec58ca063dc7c1..4c9e7b9436bf24f97cc8a275f6a5a69776bc12b1 100644 (file)
@@ -1732,8 +1732,12 @@ switch_decision_tree::try_switch_expansion (vec<cluster *> &clusters)
   /* Do not do an extra work for a single cluster.  */
   if (clusters.length () == 1
       && clusters[0]->get_type () != SIMPLE_CASE)
-    clusters[0]->emit (index_expr, index_type,
-                      gimple_switch_default_label (m_switch), m_default_bb);
+    {
+      cluster *c = clusters[0];
+      c->emit (index_expr, index_type,
+              gimple_switch_default_label (m_switch), m_default_bb);
+      redirect_edge_succ (single_succ_edge (bb), c->m_case_bb);
+    }
   else
     {
       emit (bb, index_expr, default_edge->probability, index_type);