]> git.ipfire.org Git - thirdparty/gcc.git/commit
Only do switch bit test clustering when multiple labels point to same bb
authorAndi Kleen <ak@gcc.gnu.org>
Wed, 16 Oct 2024 21:07:18 +0000 (14:07 -0700)
committerAndi Kleen <ak@gcc.gnu.org>
Tue, 29 Oct 2024 22:08:11 +0000 (15:08 -0700)
commita4e2b13888267f2581ac03f076aa0d32cd045adb
tree16bd2df2b6c166c2e53d56d7a270c447918155df
parent06bc3a734e88908cad1d3bf547a722b3f9597a0d
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.
gcc/gimple-if-to-switch.cc
gcc/tree-switch-conversion.cc
gcc/tree-switch-conversion.h