]> git.ipfire.org Git - thirdparty/gcc.git/commit
tree-optimization/107767 - not profitable switch conversion
authorRichard Biener <rguenther@suse.de>
Mon, 9 Jan 2023 08:42:22 +0000 (09:42 +0100)
committerRichard Biener <rguenther@suse.de>
Wed, 11 Jan 2023 12:13:50 +0000 (13:13 +0100)
commitf99d7d669eaa2830eb5878df4da67e77ec791522
treefeea70ad9071ddde1440fbb8c422c964fa23699d
parentb39c1bea5bae9aee1df25cab1064f983b9ec6941
tree-optimization/107767 - not profitable switch conversion

When the CFG has not merged equal PHI defs in a switch stmt the
cost model from switch conversion gets off and we prefer a
jump table over branches.  The following fixes that by recording
cases that will be merged later and more appropriately counting
unique values.

PR tree-optimization/107767
* tree-cfgcleanup.cc (phi_alternatives_equal): Export.
* tree-cfgcleanup.h (phi_alternatives_equal): Declare.
* tree-switch-conversion.cc (switch_conversion::collect):
Count unique non-default targets accounting for later
merging opportunities.

* gcc.dg/tree-ssa/pr107767.c: New testcase.
gcc/testsuite/gcc.dg/tree-ssa/pr107767.c [new file with mode: 0644]
gcc/tree-cfgcleanup.cc
gcc/tree-cfgcleanup.h
gcc/tree-switch-conversion.cc