[llvm-commits] SimplifyCFG patch

Duncan Sands baldrick at free.fr
Fri Oct 5 00:56:08 PDT 2012


Hi Jakub,

On 03/10/12 01:07, Jakub Staszak wrote:
> This patch improves SimplifyCFG, so it can handle cases where switch case and default block set the same values. Currently LLVM partially does it, however order of the cases matters, so tests from the patch weren't covered.
>
> Comments are welcome.

I'm not sure why it matters than one case is the default case: if two
cases are going to the same place, only via a pointless intermediate
block of the kind you detect, shouldn't they be merged too?  Also, what
if the block the case jumps to has several predecessors and a phi node,
then I think the transform you do is invalid.

Anyway, instead of this transform, how about having a more general
transform (nothing to do with switches) that if it sees a basic block

useless:
   some debug stuff here
   br other_block

tries to reroute all predecessors of useless to other_block.  In fact,
doesn't simplifycfg do this already?  In which case, why isn't it
kicking in...

Ciao, Duncan.



More information about the llvm-commits mailing list