Commits

Mark Lacey committed 8cbefaeef47
During DCE, eliminate branches to dead regions of code. Enhances DCE to make unreachable those regions of code that have no effect. This allows loops like: for i in 0..n { // do nothing } to be eliminated by first running DCE to make the loop unreachable, and the CFG simplification to actually delete the blocks that make up the loop (assuming we're talking -Ofast and cond_fails have been removed). What's especially nice is that this can make unreachable several levels of dead code, including deleting the code that produces the values used to conditionally branch to other dead code, all in a single pass rather than needing to iterate between DCE and CFG simplification to achieve the same effect. For example, this: func f(b: Bool, c: Bool, d: Bool) { if (b && c) { // nothing useful here if (c && d) { // nothing useful here if (b && d) { // nothing useful here } } } } is effectively reduced to: func f(b: Bool, c: Bool, d: Bool) { goto end // pretend for a second we have goto if (b && c) { // nothing useful here if (c && d) { // nothing useful here if (b && d) { // nothing useful here } } } end: } after a single pass, after which unreachable code elimination reduces this to: func f(b: Bool, c: Bool, d: Bool) { } Swift SVN r18664