diff mbox series

Fix bit-test expansion for single cluster (PR tree-optimization/86263).

Message ID 577f2347-13d6-f49f-60c8-9080cc3e9d3d@suse.cz
State New
Headers show
Series Fix bit-test expansion for single cluster (PR tree-optimization/86263). | expand

Commit Message

Martin Liška June 28, 2018, 1:25 p.m. UTC
Hi.

I'm sending patch for situation where we create a bit-test for
entire switch. In that case split BB must be redirected so that
the original switch is a dead code.

Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.

Ready to be installed?
Martin

gcc/ChangeLog:

2018-06-28  Martin Liska  <mliska@suse.cz>

        PR tree-optimization/86263
	* tree-switch-conversion.c (switch_decision_tree::try_switch_expansion):
        Make edge redirection.
---
 gcc/tree-switch-conversion.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Richard Biener June 29, 2018, 7:14 a.m. UTC | #1
On Thu, Jun 28, 2018 at 9:06 PM Martin Liška <mliska@suse.cz> wrote:
>
> Hi.
>
> I'm sending patch for situation where we create a bit-test for
> entire switch. In that case split BB must be redirected so that
> the original switch is a dead code.
>
> Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.
>
> Ready to be installed?

Testcase?

OK with one added.

Thanks,
Richard.

> Martin
>
> gcc/ChangeLog:
>
> 2018-06-28  Martin Liska  <mliska@suse.cz>
>
>         PR tree-optimization/86263
>         * tree-switch-conversion.c (switch_decision_tree::try_switch_expansion):
>         Make edge redirection.
> ---
>  gcc/tree-switch-conversion.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
>
diff mbox series

Patch

diff --git a/gcc/tree-switch-conversion.c b/gcc/tree-switch-conversion.c
index b79f2fdb6e6..4c9e7b9436b 100644
--- a/gcc/tree-switch-conversion.c
+++ b/gcc/tree-switch-conversion.c
@@ -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);