On Fri, Apr 20, 2012 at 10:52 AM, Jan Hubicka <hubi...@ucw.cz> wrote: >> On Thu, Apr 19, 2012 at 5:16 PM, Steven Bosscher <stevenb....@gmail.com> >> wrote: >> > Hello, >> > >> > If we want to use profiling to expand switches in GIMPLE, we'll have >> > to run switch-conversion after profiling. >> > >> > Bootstrapped and tested on x86_64-unknown-linux-gnu. OK? >> >> That's too early still. Profile data is not read until >> pass_ipa_tree_profile. > > Good point ;) > >> Which means moving it to after all IPA transforms (and thus run at LTRANS >> stage with LTO) would be better. May I suggest to move it after the >> DCE pass that runs after the first VRP pass? > > The original motivation to do switch conversion early was to get function > bodies smaller (i.e. when inlining the static var don't need duplication, the > switch code does) > > This was motivated by real world examples, i.e. mesa that inlines function > converting > error codes into strings. At one point we estimated it to be of 0 size > (because it > has only switch that was ignored and string constants that are zero cost) and > we > ended up completely exploding by inlining it everywhere.
Well, I never really believed this theory ;) > I think we should retain this and perhaps have always win conversions done > early > and real coversion (of switches to decision trees) done much later. > Switch expansion hides what the code really does and some of the late > optimizers > will probably benefit from knowing that switch is really a switch. > > I would expect that somewhere before second VRP makes most sense. No, I think before loop opts it makes most sense as you can end up creating vectorizable code. After first VRP because such VRP can remove dead cases. Richard. > Honza