On Mon, Nov 18, 2019 at 10:17:56AM +0100, Martin Liška wrote: > On 11/14/19 1:15 PM, Richard Biener wrote: > > Hmm. I was thinking of moving the pass instead of adding another one. > > What's the reason to run switch-conversion during early optimization again? > > I'm adding CC, as he's the author of cswitch pass and he probably knows > more about the pass placement. But I bet early conversion to array access > rapidly simplifies CFG and other passes can benefit from that.
Yes, I think the early placement is to take it into account in inlining decisions, on the other side it causes various issues, I think we have several PRs open where the early cswitch just makes a good decision based on what it knows at that point, but later on we find better VRP ranges for the switch condition and it is too late to undo it and handle it differently. So, perhaps if we could during early cswitch just annotate the gswitch that it would be optimized that way (table lookup, ...), but not actually modify the switch and let inlininer use that info and then perform a late gswitch that would actually optimize it, or let early cswitch perform the transformation, but annotate it so that late cswitch could undo it and perform it differently. Another thing is perform the optimizations we do in reassoc (but aren't effective anymore after your if to gswitch changes) on switches too, most likely during the (late?) cswitch pass. Jakub