[LICM] Don't try to promote in loops where we have no chance to promote. NFC.

We would check whether we have a prehader *or* dedicated exit blocks,
and go into the promotion loop. Then, for each alias set we'd check
if we have a preheader *and* dedicated exit blocks, and bail if not.

Instead, bail immediately if we don't have both.

llvm-svn: 290728
This commit is contained in:
Michael Kuperstein 2016-12-29 22:51:22 +00:00
parent 8604783a3f
commit 5566092963
1 changed files with 6 additions and 10 deletions

View File

@ -250,7 +250,12 @@ bool LoopInvariantCodeMotion::runOnLoop(Loop *L, AliasAnalysis *AA,
// Now that all loop invariants have been removed from the loop, promote any
// memory references to scalars that we can.
if (!DisablePromotion && (Preheader || L->hasDedicatedExits())) {
// Don't sink stores from loops without dedicated block exits. Exits
// containing indirect branches are not transformed by loop simplify,
// make sure we catch that. An additional load may be generated in the
// preheader for SSA updater, so also avoid sinking when no preheader
// is available.
if (!DisablePromotion && Preheader && L->hasDedicatedExits()) {
SmallVector<BasicBlock *, 8> ExitBlocks;
SmallVector<Instruction *, 8> InsertPts;
PredIteratorCache PIC;
@ -909,15 +914,6 @@ bool llvm::promoteLoopAccessesToScalars(
// us to prove better alignment.
unsigned Alignment = 1;
AAMDNodes AATags;
bool HasDedicatedExits = CurLoop->hasDedicatedExits();
// Don't sink stores from loops without dedicated block exits. Exits
// containing indirect branches are not transformed by loop simplify,
// make sure we catch that. An additional load may be generated in the
// preheader for SSA updater, so also avoid sinking when no preheader
// is available.
if (!HasDedicatedExits || !Preheader)
return false;
const DataLayout &MDL = Preheader->getModule()->getDataLayout();