https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103278
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|rguenth at gcc dot gnu.org |unassigned at gcc dot gnu.org Status|RESOLVED |NEW Resolution|FIXED |--- --- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> --- So for rl78-elf if-to-switch-5 we fail the JT because it's not enabled for the target. 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(?). After the CD-DCE change we have improved(?) clusters: ;; Canonical GIMPLE case clusters: 34 39 44 46 58-60 62 92 and thus the output is no longer(?) beneficial. 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 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?