[PATCH] LowerSwitch: replace unreachable default with popular case destination

Marcello Maggioni hayarms at gmail.com
Thu Jan 15 18:31:55 PST 2015

I still see some potential drawbacks on some CFGs.

Lets take this example, derived from your original test:

F342679: test.ll <http://reviews.llvm.org/F342679>

In this case there is a gap between the values of the cases.
Your Min/MaxCase approach works fine on the edges of the range of the cases, but doesn't do anything in the case there is a gap between cases.
If there is a gap between the cases the fact that there is no Default block still gives us the possibility to avoid having to check if the value falls into the gap or not.
Basically we are still losing the boundary information on the bounds that fall on gaps.

Here are the CFG of the example with and without your patch.

Maybe there is a way to actually also check for the boundaries on the gaps and integrating them in the algorithm.
I have to think about it, maybe we can also speak about it on IRC if you want :-)

F342683: with_patch.pdf <http://reviews.llvm.org/F342683>

F342684: without_patch.pdf <http://reviews.llvm.org/F342684>



More information about the llvm-commits mailing list