Note that we're pointlessly testing whether x == 1 at 0x0005. We should be able to eliminate that test. Probably the easiest place is when lowering the switch statement; if there is no default case, then any cases with empty bodies can be removed. (Taking care to evaluate the case expressions if necessary, of course, and taking care with pointless fallthroughs from the previous case.) Another possibility, probably more powerful, is to detect the unnecessary branch somehow in SSA form.
This kind of code arises naturally when wanting to make it clear to the reader that a particular case has been considered by the code author. It also shows up in generated code.
The text was updated successfully, but these errors were encountered: