[LICM] Extract a helper function for readability [NFC]

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339069 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Philip Reames
2018-08-06 22:07:37 +00:00
parent f06afc396f
commit 418492e425
+12 -8
View File
@@ -588,6 +588,16 @@ bool isHoistableAndSinkableInst(Instruction &I) {
isa<ExtractElementInst>(I) || isa<ShuffleVectorInst>(I) ||
isa<ExtractValueInst>(I) || isa<InsertValueInst>(I));
}
/// Return true if all of the alias sets within this AST are known not to
/// contain a Mod.
bool isReadOnly(AliasSetTracker *CurAST) {
for (AliasSet &AS : *CurAST) {
if (!AS.isForwardingAliasSet() && AS.isMod()) {
return false;
}
}
return true;
}
}
bool llvm::canSinkOrHoistInst(Instruction &I, AAResults *AA, DominatorTree *DT,
@@ -663,16 +673,10 @@ bool llvm::canSinkOrHoistInst(Instruction &I, AAResults *AA, DominatorTree *DT,
return false;
return true;
}
// If this call only reads from memory and there are no writes to memory
// in the loop, we can hoist or sink the call as appropriate.
bool FoundMod = false;
for (AliasSet &AS : *CurAST) {
if (!AS.isForwardingAliasSet() && AS.isMod()) {
FoundMod = true;
break;
}
}
if (!FoundMod)
if (isReadOnly(CurAST))
return true;
}