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

Hans Wennborg hans at chromium.org
Fri Dec 5 18:02:00 PST 2014


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?

 - Hans




More information about the llvm-commits mailing list