[LoopInterchange] Move preheader creation to transform stage and simplify.
authorFlorian Hahn <florian.hahn@arm.com>
Thu, 6 Sep 2018 09:57:27 +0000 (09:57 +0000)
committerFlorian Hahn <florian.hahn@arm.com>
Thu, 6 Sep 2018 09:57:27 +0000 (09:57 +0000)
commit236f6feb8f931e7bd45304e35ec775d4b5da64a6
tree5e40a8faaacb9a12252d46296ffb31963d0832cc
parent20c88ebf5774429fa76d603186370f283323a939
[LoopInterchange] Move preheader creation to transform stage and simplify.

There is no need to create preheaders in the analysis stage, we only
need them when adjusting the branches. Also, the only cases we need to
create our own preheaders is when they have more than 1 predecessors or
PHI nodes (even with only 1 predecessor, we could have an LCSSA phi
node). I have simplified the conditions and added some assertions to be
sure. Because we know the inner and outer loop need to be tightly
nested, it is sufficient to check if the inner loop preheader is the
outer loop header to check if we need to create a new preheader.

Reviewers: efriedma, mcrosier, karthikthecool

Reviewed By: efriedma

Differential Revision: https://reviews.llvm.org/D51703

llvm-svn: 341533
llvm/lib/Transforms/Scalar/LoopInterchange.cpp