[LoopPredication] NFC. Extract CanExpand helper lambda

llvm-svn: 303425
This commit is contained in:
Artur Pilipenko 2017-05-19 14:00:04 +00:00
parent 46c4e0a4bf
commit aab28666bc
1 changed files with 6 additions and 2 deletions

View File

@ -141,7 +141,11 @@ Optional<Value *> LoopPredication::widenICmpRangeCheck(ICmpInst *ICI,
std::swap(LHSS, RHSS);
Pred = ICmpInst::getSwappedPredicate(Pred);
}
if (!SE->isLoopInvariant(RHSS, L) || !isSafeToExpand(RHSS, *SE))
auto CanExpand = [this](const SCEV *S) {
return SE->isLoopInvariant(S, L) && isSafeToExpand(S, *SE);
};
if (!CanExpand(RHSS))
return None;
const SCEVAddRecExpr *IndexAR = dyn_cast<SCEVAddRecExpr>(LHSS);
@ -170,7 +174,7 @@ Optional<Value *> LoopPredication::widenICmpRangeCheck(ICmpInst *ICI,
DEBUG(dbgs() << "NewLHSS: ");
DEBUG(NewLHSS->dump());
if (!SE->isLoopInvariant(NewLHSS, L) || !isSafeToExpand(NewLHSS, *SE))
if (!CanExpand(NewLHSS))
return None;
DEBUG(dbgs() << "NewLHSS is loop invariant and safe to expand. Expand!\n");