https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117091
--- Comment #4 from ak at gcc dot gnu.org --- Here's a patch that enables the slow switch conversions only at -O2. With that the test case builds reasonably quickly. diff --git a/gcc/common.opt b/gcc/common.opt index 12b25ff486de..4af7a94fea42 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -2189,11 +2189,11 @@ Common Var(flag_ivopts) Init(1) Optimization Optimize induction variables on trees. fjump-tables -Common Var(flag_jump_tables) Init(1) Optimization +Common Var(flag_jump_tables) Init(-1) Optimization Use jump tables for sufficiently large switch statements. fbit-tests -Common Var(flag_bit_tests) Init(1) Optimization +Common Var(flag_bit_tests) Init(-1) Optimization Use bit tests for sufficiently large switch statements. fkeep-inline-functions diff --git a/gcc/tree-switch-conversion.h b/gcc/tree-switch-conversion.h index 6468995eb316..1cca23671d70 100644 --- a/gcc/tree-switch-conversion.h +++ b/gcc/tree-switch-conversion.h @@ -442,7 +442,7 @@ public: /* Return whether bit test expansion is allowed. */ static inline bool is_enabled (void) { - return flag_bit_tests; + return flag_bit_tests >= 0 ? flag_bit_tests : (optimize > 1); } /* True when the jump table handles an entire switch statement. */ @@ -524,7 +524,8 @@ bool jump_table_cluster::is_enabled (void) over-ruled us, we really have no choice. */ if (!targetm.have_casesi () && !targetm.have_tablejump ()) return false; - if (!flag_jump_tables) + int flag = flag_jump_tables >= 0 ? flag_jump_tables : (optimize > 1); + if (!flag) return false; #ifndef ASM_OUTPUT_ADDR_DIFF_ELT if (flag_pic)