From 3f10efd4ee4d62d2d7a94e518a3873687399879e Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Fri, 29 Jun 2018 12:57:00 +0200 Subject: [PATCH] Fix bit-test expansion for single cluster (PR tree-optimization/86263). 2018-06-29 Martin Liska PR tree-optimization/86263 * tree-switch-conversion.c (switch_decision_tree::try_switch_expansion): Make edge redirection. 2018-06-29 Martin Liska PR tree-optimization/86263 * gcc.dg/tree-ssa/pr86263.c: New test. From-SVN: r262247 --- gcc/ChangeLog | 6 +++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/tree-ssa/pr86263.c | 29 +++++++++++++++++++++++++ gcc/tree-switch-conversion.c | 8 +++++-- 4 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr86263.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5c7c5022123..44012454e27 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2018-06-29 Martin Liska + + PR tree-optimization/86263 + * tree-switch-conversion.c (switch_decision_tree::try_switch_expansion): + Make edge redirection. + 2018-06-29 David Malcolm * dumpfile.c (dump_loc): Add indentation based on scope depth. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 58860c7aebd..a9f7fd96662 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-06-29 Martin Liska + + PR tree-optimization/86263 + * gcc.dg/tree-ssa/pr86263.c: New test. + 2018-06-28 Carl Love * 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 index 00000000000..7f80c22e67b --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr86263.c @@ -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; +} 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 &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); -- 2.30.2