[polly] r255776 - ScopInfo: Introduce getNumberOfArrayAccesses
Tobias Grosser via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 16 08:14:00 PST 2015
Author: grosser
Date: Wed Dec 16 10:14:00 2015
New Revision: 255776
URL: http://llvm.org/viewvc/llvm-project?rev=255776&view=rev
Log:
ScopInfo: Introduce getNumberOfArrayAccesses
Use the new function to clarify that we indeed only want to know it at least
one array access is associated with an instruction.
Modified:
polly/trunk/include/polly/ScopInfo.h
polly/trunk/lib/Analysis/ScopInfo.cpp
Modified: polly/trunk/include/polly/ScopInfo.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopInfo.h?rev=255776&r1=255775&r2=255776&view=diff
==============================================================================
--- polly/trunk/include/polly/ScopInfo.h (original)
+++ polly/trunk/include/polly/ScopInfo.h Wed Dec 16 10:14:00 2015
@@ -992,6 +992,29 @@ public:
return *ArrayAccess;
}
+ /// @brief Get the number of array accesses associated with an instruction.
+ ///
+ /// @param Inst The instruction for which to obtain the access count.
+ /// @returns The number of array accesses associated with this instruction.
+ size_t getNumberOfArrayAccessesFor(const Instruction *Inst) const {
+ size_t NumAccesses = 0;
+ auto It = InstructionToAccess.find(Inst);
+ if (It == InstructionToAccess.end())
+ return 0;
+
+ auto *Accesses = It->getSecond();
+
+ if (!Accesses)
+ return 0;
+
+ for (auto Access : *Accesses) {
+ if (Access->isArrayKind())
+ NumAccesses++;
+ }
+
+ return NumAccesses;
+ }
+
/// @brief Return the __first__ (scalar) memory access for @p Inst if any.
MemoryAccess *lookupAccessFor(const Instruction *Inst) const {
auto It = InstructionToAccess.find(Inst);
Modified: polly/trunk/lib/Analysis/ScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=255776&r1=255775&r2=255776&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/ScopInfo.cpp Wed Dec 16 10:14:00 2015
@@ -2923,7 +2923,7 @@ void Scop::verifyInvariantLoads() {
for (LoadInst *LI : RIL) {
assert(LI && getRegion().contains(LI));
ScopStmt *Stmt = getStmtForBasicBlock(LI->getParent());
- if (Stmt && Stmt->lookupAccessesFor(LI)) {
+ if (Stmt && Stmt->getNumberOfArrayAccessesFor(LI) > 0) {
invalidate(INVARIANTLOAD, LI->getDebugLoc());
return;
}
More information about the llvm-commits
mailing list