[NFC] Refactor LICM code for better readability

llvm-svn: 354013
This commit is contained in:
Max Kazantsev 2019-02-14 09:04:12 +00:00
parent bc47289511
commit deaf2ba280
1 changed files with 11 additions and 6 deletions

View File

@ -856,13 +856,18 @@ bool llvm::hoistRegion(DomTreeNode *N, AliasAnalysis *AA, LoopInfo *LI,
continue; continue;
} }
using namespace PatternMatch; auto IsInvariantStart = [&](Instruction &I) {
if (((I.use_empty() && using namespace PatternMatch;
match(&I, m_Intrinsic<Intrinsic::invariant_start>())) || return I.use_empty() &&
isGuard(&I)) && match(&I, m_Intrinsic<Intrinsic::invariant_start>());
};
auto MustExecuteWithoutWritesBefore = [&](Instruction &I) {
return SafetyInfo->isGuaranteedToExecute(I, DT, CurLoop) &&
SafetyInfo->doesNotWriteMemoryBefore(I, CurLoop);
};
if ((IsInvariantStart(I) || isGuard(&I)) &&
CurLoop->hasLoopInvariantOperands(&I) && CurLoop->hasLoopInvariantOperands(&I) &&
SafetyInfo->isGuaranteedToExecute(I, DT, CurLoop) && MustExecuteWithoutWritesBefore(I)) {
SafetyInfo->doesNotWriteMemoryBefore(I, CurLoop)) {
hoist(I, DT, CurLoop, CFH.getOrCreateHoistedBlock(BB), SafetyInfo, hoist(I, DT, CurLoop, CFH.getOrCreateHoistedBlock(BB), SafetyInfo,
MSSAU, ORE); MSSAU, ORE);
HoistedInstructions.push_back(&I); HoistedInstructions.push_back(&I);