https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117091
--- Comment #17 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The trunk branch has been updated by Andi Kleen <a...@gcc.gnu.org>: https://gcc.gnu.org/g:a4e2b13888267f2581ac03f076aa0d32cd045adb commit r15-4757-ga4e2b13888267f2581ac03f076aa0d32cd045adb Author: Andi Kleen <a...@gcc.gnu.org> Date: Wed Oct 16 14:07:18 2024 -0700 Only do switch bit test clustering when multiple labels point to same bb The bit cluster code generation strategy is only beneficial when multiple case labels point to the same code. Do a quick check if that is the case before trying to cluster. This fixes the switch part of PR117091 where all case labels are unique however it doesn't address the performance problems for non unique cases. gcc/ChangeLog: PR middle-end/117091 * gimple-if-to-switch.cc (if_chain::is_beneficial): Update find_bit_test call. * tree-switch-conversion.cc (bit_test_cluster::find_bit_tests): Get max_c argument and bail out early if all case labels are unique. (switch_decision_tree::compute_cases_per_edge): Record number of targets per label and return. (switch_decision_tree::analyze_switch_statement): ... pass to find_bit_tests. * tree-switch-conversion.h: Update prototypes.