forked from OSchip/llvm-project
[NFC] Refactor LICM code for better readability
llvm-svn: 354013
This commit is contained in:
parent
bc47289511
commit
deaf2ba280
|
@ -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);
|
||||||
|
|
Loading…
Reference in New Issue