[PATCH] SimplifyCFG: don't remove unreachable defaults from switch instructions; exploit them instead!

Tom Stellard tom at stellard.net
Fri Dec 5 18:29:01 PST 2014


On Fri, Dec 05, 2014 at 06:02:00PM -0800, Hans Wennborg wrote:
> On Fri, Dec 5, 2014 at 5:47 PM, Owen Anderson <resistor at mac.com> wrote:
> >
> > On Dec 5, 2014, at 3:24 PM, Hans Wennborg <hans at chromium.org> wrote:
> >
> > ! In D6471#14, @resistor wrote:
> >
> > Can you update LowerSwitch.cpp to incorporate this optimization?  Otherwise
> > targets that rely on it are losing this functionality.
> >
> >
> > It seems LowerSwitch.cpp is already set up to exploit unreachable defaults,
> > see the test in
> > test/Transforms/LowerSwitch/2014-06-11-SwitchDefaultUnreachableOpt.ll
> >
> > I guess it's a choice of whether that's important, or if moving popular
> > cases into the default is better. If it's the latter I'm happy to implement
> > it.
> >
> > http://reviews.llvm.org/D6471
> >
> >
> > I don’t have any particular knowledge that LowerSwitch is doing something
> > undesirable, I just wanted to make sure we aren’t losing existing
> > functionality on that path.
> 
> I'm just saying that if I incorporate the "replace default with most
> popular case" transform into LowerSwitch, then the current code that
> looks for unreachable default will never fire.
> 
> But maybe that's not a problem because if you normally run SimplifyCFG
> before LowerSwitch, that's already happening.
> 
> I'm not really familiar with the intended use of LowerSwitch. Is it
> used for targets that don't use the SDAG/FastISel lowering?
> 

The StructurizeCFG pass depends on LowerSwitch to eliminate all switch
instructions, because it doesn't know how to handle them.

-Tom

>  - Hans
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list