The SimplifyCFG pass currently contains two transformations for switches that can obscure flow and inhibit other optimisations:
- switch of constants is replaced with look-up table
- sparse switches are replaced with transformation of the condition to make them dense
Most importantly, both transformations can benefit from DCE as a result of CVP and inlining. At the same time, they can inhibit inlining when run before the corresponding module pass as part of the early function cleanup. Neither transform looks like it is very useful early on, so split the existing simplifycfg pass into two and replace the last instance in the normal pass pipeline with the latesimplifycfg pass.
Initial testing of a version covering only point (1) of the list above fixes the regression in PR 32003. A LNT run by Mehdi Amini of the same versions shows:
MultiSource/Benchmarks/ASC_Sequoia/CrystalMk/CrystalMk 2.5% slower
SingleSource/Benchmarks/Misc/matmul_f64_4x4 34.2% faster
SingleSource/Benchmarks/Misc/fp-convert 3.0% faster
MultiSource/Benchmarks/Prolangs-C++/life/life 2.8% faster
This is still interleaved with inlining; is that intentional?