https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103278
--- Comment #11 from Martin Liška <marxin at gcc dot gnu.org> --- (In reply to Richard Biener from comment #9) > So for > > rl78-elf > if-to-switch-5 > > we fail the JT because it's not enabled for the target. Yes. > w/o the CD-DCE > change we build a bit-test from > > ;; Canonical GIMPLE case clusters: 34 39 44 46 58 59 60 62 92 > > which we then expand into a new switch without any bit tests(?). No, the message just tells what's the canonical switch form and the transformation doesn't happen. > After the CD-DCE change we have improved(?) clusters: > > ;; Canonical GIMPLE case clusters: 34 39 44 46 58-60 62 92 Which is nicer! > > and thus the output is no longer(?) beneficial. Yes, because BT counts the number of edges in the costing model and this is definitelly more precise. Does not make sense doing a BT for 10-30 even though it's theoretically 21 edges. > > I wonder if the merging of clusters done as part of the sorting is > counter-productive since it distorts the profitability? If we check against > the > size of the unmerged clusters like with the following the testcase > will pass again. I also notice we don't take advantage of the > merging and create The costing is not improved by the change. > > switch (c_3(D)) <default: <L13> [INV], case 34: <L12> [INV], case 39: > <L12> [INV], case 44: <L12> [INV], case 46: <L12> [INV], case 58: <L12> > [INV], case 59: <L12> [INV], case 60: <L12> [INV], case 62: <L12> [INV], > case 92: <L12> [INV]> > > instead of one 'case 58-60:' > > diff --git a/gcc/gimple-if-to-switch.cc b/gcc/gimple-if-to-switch.cc > index 16fabef7ca0..b64a1915e15 100644 > --- a/gcc/gimple-if-to-switch.cc > +++ b/gcc/gimple-if-to-switch.cc > @@ -240,7 +240,7 @@ if_chain::is_beneficial () > > vec<cluster *> output > = jump_table_cluster::find_jump_tables (filtered_clusters); > - bool r = output.length () < filtered_clusters.length (); > + bool r = output.length () < clusters.length (); > if (r) > { > dump_clusters (&output, "JT can be built"); > @@ -251,7 +251,7 @@ if_chain::is_beneficial () > output.release (); > > output = bit_test_cluster::find_bit_tests (filtered_clusters); > - r = output.length () < filtered_clusters.length (); > + r = output.length () < clusters.length (); > if (r) > dump_clusters (&output, "BT can be built"); > > > Martin, can you please look into this? Sure, I tend to change the test in the following way: gcc/testsuite/gcc.dg/tree-ssa/if-to-switch-5.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gcc/testsuite/gcc.dg/tree-ssa/if-to-switch-5.c b/gcc/testsuite/gcc.dg/tree-ssa/if-to-switch-5.c index ceeae908821..54771e64e59 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/if-to-switch-5.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/if-to-switch-5.c @@ -4,8 +4,8 @@ int crud (unsigned char c) { return (((((((((((int) c == 46) || (int) c == 44) - || (int) c == 58) || (int) c == 59) || (int) c == 60) - || (int) c == 62) || (int) c == 34) || (int) c == 92) + || (int) c == 58) || (int) c == 60) || (int) c == 62) + || (int) c == 64) || (int) c == 34) || (int) c == 92) || (int) c == 39) != 0); }