https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117091
--- Comment #2 from ak at gcc dot gnu.org --- Minimum patch. Only enable the clustering at -O2. diff --git a/gcc/tree-switch-conversion.cc b/gcc/tree-switch-conversion.cc index 00426d400006..468b15f1c461 100644 --- a/gcc/tree-switch-conversion.cc +++ b/gcc/tree-switch-conversion.cc @@ -1375,7 +1375,8 @@ switch_conversion::expand (gswitch *swtch) gcc_checking_assert (TREE_TYPE (m_index_expr) != error_mark_node); /* Prefer bit test if possible. */ - if (tree_fits_uhwi_p (m_range_size) + if (optimize >= 2 + && tree_fits_uhwi_p (m_range_size) && bit_test_cluster::can_be_handled (tree_to_uhwi (m_range_size), m_uniq) && bit_test_cluster::is_beneficial (m_count, m_uniq)) {