1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-21 03:53:04 +02:00
llvm-mirror/include/llvm/Transforms
Chandler Carruth bf90c00391 [PM/LoopUnswitch] Teach the new unswitch to handle nontrivial
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
2018-06-25 23:32:54 +00:00
..
AggressiveInstCombine Fix some layering in AggressiveInstCombine (avoiding inclusion of Scalar.h) 2018-04-24 15:40:07 +00:00
InstCombine Rename DEBUG macro to LLVM_DEBUG. 2018-05-14 12:53:11 +00:00
Instrumentation Fix Layering, move instrumentation transform headers into Instrumentation subdirectory 2018-03-23 22:11:06 +00:00
IPO Move SampleProfile.h into IPO along with the rest of the IPO pass headers 2018-03-22 22:42:44 +00:00
Scalar [PM/LoopUnswitch] Teach the new unswitch to handle nontrivial 2018-06-25 23:32:54 +00:00
Utils Revert r335324 due to a builtbot failure 2018-06-22 08:57:01 +00:00
Vectorize Remove \brief commands from doxygen comments. 2018-05-01 15:54:18 +00:00
Coroutines.h [coroutines] Part 3 of N: Adding Boilerplate for Coroutine Passes 2016-07-28 21:04:31 +00:00
Instrumentation.h Revert r335306 (and r335314) - the Call Graph Profile pass. 2018-06-22 05:33:57 +00:00
IPO.h Remove \brief commands from doxygen comments. 2018-05-01 15:54:18 +00:00
ObjCARC.h Revert r240137 (Fixed/added namespace ending comments using clang-tidy. NFC) 2015-06-23 09:49:53 +00:00
Scalar.h Revert 333358 as it's failing on some builders. 2018-05-27 12:54:33 +00:00
Utils.h Fix some layering in StripNonLineTableDebugInfo, moving its declaration from IPO.h to Utils.h to match its implementation 2018-03-29 22:42:08 +00:00
Vectorize.h Remove @brief commands from doxygen comments, too. 2018-05-01 16:10:38 +00:00