Add LoopSimplifyCFG pass
authorFiona Glaser <escha@apple.com>
Fri, 29 Jan 2016 22:35:36 +0000 (22:35 +0000)
committerFiona Glaser <escha@apple.com>
Fri, 29 Jan 2016 22:35:36 +0000 (22:35 +0000)
commitb417d464e6f749a27a2ec778f5c87c1e462b36aa
tree56f2bc16c1b0dd1ddb05d99c2f91acf26497875e
parent9c98105002f4755e2daef174112db7016c697f87
Add LoopSimplifyCFG pass

Loop transformations can sometimes fail because the loop, while in
valid rotated LCSSA form, is not in a canonical CFG form. This is
an extremely simple pass that just merges obviously redundant
blocks, which can be used to fix some known failure cases. In the
future, it may be enhanced with more cases (and have code shared with
SimplifyCFG).

This allows us to run LoopSimplifyCFG -> LoopRotate -> LoopUnroll,
so that SimplifyCFG cleans up the loop before Rotate tries to run.

Not currently used in the pass manager, since this pass doesn't do
anything unless you can hook it up in an LPM with other loop passes.
It'll be added once Chandler cleans up things to allow this.

Tested in a custom pipeline out of tree to confirm it works in
practice (in addition to the included trivial test).

llvm-svn: 259256
llvm/include/llvm/InitializePasses.h
llvm/include/llvm/LinkAllPasses.h
llvm/include/llvm/Transforms/Scalar.h
llvm/lib/Transforms/Scalar/CMakeLists.txt
llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp [new file with mode: 0644]
llvm/lib/Transforms/Scalar/Scalar.cpp
llvm/test/Transforms/LoopSimplifyCFG/merge-header.ll [new file with mode: 0644]