[LoopUnrolling] Peel loops with invariant backedge Phi input
authorSanjoy Das <sanjoy@playingwithpointers.com>
Fri, 3 Mar 2017 18:19:15 +0000 (18:19 +0000)
committerSanjoy Das <sanjoy@playingwithpointers.com>
Fri, 3 Mar 2017 18:19:15 +0000 (18:19 +0000)
commit664c925a5712d5977b244868c652e158b600af04
treefe7c9ba0c55d543be49391e6792dfd19e147589c
parenteed71b9e1ccd4d04f47eb3372a8a39a6aea980a8
[LoopUnrolling] Peel loops with invariant backedge Phi input

Summary:
If a loop contains a Phi node which has an invariant input from back
edge, it is profitable to peel such loops (rather than unroll them) to
use the advantage that this Phi is always invariant starting from 2nd
iteration. After the 1st iteration is peeled, other optimizations can
potentially simplify calculations with this invariant.

Patch by Max Kazantsev!

Reviewers: sanjoy, apilipenko, igor-laevsky, anna, mkuper, reames

Reviewed By: mkuper

Subscribers: mkuper, mzolotukhin, llvm-commits

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

llvm-svn: 296898
llvm/lib/Transforms/Utils/LoopUnrollPeel.cpp
llvm/test/Transforms/LoopUnroll/peel-loop-not-forced.ll [new file with mode: 0644]