[llvm] r339069 - [LICM] Extract a helper function for readability [NFC]
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 6 15:07:37 PDT 2018
Author: reames
Date: Mon Aug 6 15:07:37 2018
New Revision: 339069
URL: http://llvm.org/viewvc/llvm-project?rev=339069&view=rev
Log:
[LICM] Extract a helper function for readability [NFC]
Modified:
llvm/trunk/lib/Transforms/Scalar/LICM.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/LICM.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LICM.cpp?rev=339069&r1=339068&r2=339069&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LICM.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LICM.cpp Mon Aug 6 15:07:37 2018
@@ -588,6 +588,16 @@ bool isHoistableAndSinkableInst(Instruct
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(Instructio
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;
}
More information about the llvm-commits
mailing list