mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 03:33:20 +01:00
cb049b799a
switch unswitching. The core problem was that the way we handled unswitching trivial exit edges through the default successor of a switch. For some reason I thought the right way to do this was to add a block containing unreachable and point the default successor at this block. In retrospect, this has an amazing number of problems. The first issue is the one that this pass has always worked around -- we have to *detect* such edges and avoid unswitching them again. This seemed pretty easy really. You juts look for an edge to a block containing unreachable. However, this pattern is woefully unsound. So many things can break it. The amazing thing is that I found a test case where *simple-loop-unswitch itself* breaks this! When we do a *non-trivial* unswitch of a switch we will end up splitting this exit edge. The result will be a default successor that is an exit and terminates in ... a perfectly normal branch. So the first test case that I started trying to fix is added to the nontrivial test cases. This is a ridiculous example that did just amazing things previously. With just unswitch, it would create 10+ copies of this stuff stamped out. But if you combine it *just right* with a bunch of other passes (like simplify-cfg, loop rotate, and some LICM) you can get it to do this infinitely. Or at least, I never got it to finish. =[ This, in turn, uncovered another related issue. When we are manipulating these switches after doing a trivial unswitch we never correctly updated PHI nodes to reflect our edits. As soon as I started changing how these edges were managed, it became obvious there were more issues that I couldn't realistically leave unaddressed, so I wrote more test cases around PHI updates here and ensured all of that works now. And this, in turn, required some adjustment to how we collect and manage the exit successor when it is the default successor. That showed a clear bug where we failed to include it in our search for the outer-most loop reached by an unswitched exit edge. This was actually already tested and the test case didn't work. I (wrongly) thought that was due to SCEV failing to analyze the switch. In fact, it was just a simple bug in the code that skipped the default successor. While changing this, I handled it correctly and have updated the test to reflect that we now get precise SCEV analysis of trip counts for the outer loop in one of these cases. llvm-svn: 336646 |
||
---|---|---|
.. | ||
2006-06-13-SingleEntryPHI.ll | ||
2006-06-27-DeadSwitchCase.ll | ||
2007-05-09-tl.ll | ||
2007-05-09-Unreachable.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 | ||
basictest.ll | ||
cleanuppad.ll | ||
copy-metadata.ll | ||
crash.ll | ||
exponential-behavior.ll | ||
infinite-loop.ll | ||
LIV-loop-condtion.ll | ||
msan.ll | ||
nontrivial-unswitch-cost.ll | ||
nontrivial-unswitch.ll | ||
pr37888.ll | ||
preserve-analyses.ll | ||
trivial-unswitch-iteration.ll | ||
trivial-unswitch.ll | ||
update-scev.ll |