[PATCH] LowerSwitch: replace unreachable default with popular case destination
hayarms at gmail.com
Fri Jan 16 09:42:58 PST 2015
I think there is probably a way to make it such that we take advantage of your work.
Originally, before your algorithm runs the switch case ranges have naturally holes that if the default is unreachable are unreachable as well and can be used as bounds.
Basically your algorithm detects that the Default is unreachable and adds additional holes by removing the cases that point to the most common successor.
Now though you introduce an ambiguity. Some of the holes are actually unreachable (which are the original "holes" before your algorithm run) , but some other are not (which are the ones you introduced) , but we cannot differentiate between the two.
If we instead , before running your algorithm, we collect the ranges that are true unreachable gaps and use this information in the lowering algorithm to make the best assumptions between upper and lower bounds I think we can reach the optimum.
More information about the llvm-commits