forked from OSchip/llvm-project
1652996fd6
unswitching of switches. This works much like trivial unswitching of switches in that it reliably moves the switch out of the loop. Here we potentially clone the entire loop into each successor of the switch and re-point the cases at these clones. Due to the complexity of actually doing nontrivial unswitching, this patch doesn't create a dedicated routine for handling switches -- it would duplicate far too much code. Instead, it generalizes the existing routine to handle both branches and switches as it largely reduces to looping in a few places instead of doing something once. This actually improves the results in some cases with branches due to being much more careful about how dead regions of code are managed. With branches, because exactly one clone is created and there are exactly two edges considered, somewhat sloppy handling of the dead regions of code was sufficient in most cases. But with switches, there are much more complicated patterns of dead code and so I've had to move to a more robust model generally. We still do as much pruning of the dead code early as possible because that allows us to avoid even cloning the code. This also surfaced another problem with nontrivial unswitching before which is that we weren't as precise in reconstructing loops as we could have been. This seems to have been mostly harmless, but resulted in pointless LCSSA PHI nodes and other unnecessary cruft. With switches, we have to get this *right*, and everything benefits from it. While the testing may seem a bit light here because we only have two real cases with actual switches, they do a surprisingly good job of exercising numerous edge cases. Also, because we share the logic with branches, most of the changes in this patch are reasonably well covered by existing tests. The new unswitch now has all of the same fundamental power as the old one with the exception of the single unsound case of *partial* switch unswitching -- that really is just loop specialization and not unswitching at all. It doesn't fit into the canonicalization model in any way. We can add a loop specialization pass that runs late based on profile data if important test cases ever come up here. Differential Revision: https://reviews.llvm.org/D47683 llvm-svn: 335553 |
||
---|---|---|
.. | ||
2006-06-13-SingleEntryPHI.ll | ||
2006-06-27-DeadSwitchCase.ll | ||
2007-05-09-Unreachable.ll | ||
2007-05-09-tl.ll | ||
2007-07-12-ExitDomInfo.ll | ||
2007-07-13-DomInfo.ll | ||
2007-07-18-DomInfo.ll | ||
2007-08-01-Dom.ll | ||
2007-08-01-LCSSA.ll | ||
2007-10-04-DomFrontier.ll | ||
2008-06-02-DomInfo.ll | ||
2008-06-17-DomFrontier.ll | ||
2010-11-18-LCSSA.ll | ||
2011-06-02-CritSwitch.ll | ||
2011-09-26-EHCrash.ll | ||
2012-04-02-IndirectBr.ll | ||
2012-04-30-LoopUnswitch-LPad-Crash.ll | ||
2012-05-20-Phi.ll | ||
2015-09-18-Addrspace.ll | ||
LIV-loop-condtion.ll | ||
basictest.ll | ||
cleanuppad.ll | ||
copy-metadata.ll | ||
crash.ll | ||
exponential-behavior.ll | ||
infinite-loop.ll | ||
msan.ll | ||
nontrivial-unswitch-cost.ll | ||
nontrivial-unswitch.ll | ||
pr37888.ll | ||
preserve-analyses.ll | ||
trivial-unswitch-iteration.ll | ||
trivial-unswitch.ll |