[polly] r217506 - No need to check for non-existing std::map elements

Tobias Grosser tobias at grosser.es
Wed Sep 10 07:38:12 PDT 2014


Author: grosser
Date: Wed Sep 10 09:38:12 2014
New Revision: 217506

URL: http://llvm.org/viewvc/llvm-project?rev=217506&view=rev
Log:
No need to check for non-existing std::map elements

It seems we added guards to check for non-existing std::map elements to make
sure they are default constructed before first accessed. Besides, the code
being wrong because of checking Context.NonAffineAccesses[BasePointer].size()
instead of Context.cound(BasePointer), such a check is also not necessary
as std::map takes care of this already.

>From the std::map documentation:

"If k does not match the key of any element in the container, the function
inserts a new element with that key and returns a reference to its mapped value.
Notice that this always increases the container size by one, even if no mapped
value is assigned to the element (the element is constructed using its default
constructor)."

Modified:
    polly/trunk/lib/Analysis/ScopDetection.cpp

Modified: polly/trunk/lib/Analysis/ScopDetection.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopDetection.cpp?rev=217506&r1=217505&r2=217506&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopDetection.cpp (original)
+++ polly/trunk/lib/Analysis/ScopDetection.cpp Wed Sep 10 09:38:12 2014
@@ -449,13 +449,9 @@ bool ScopDetection::isValidMemoryAccess(
     // Collect all non affine memory accesses, and check whether they are linear
     // at the end of scop detection. That way we can delinearize all the memory
     // accesses to the same array in a unique step.
-    if (Context.NonAffineAccesses[BasePointer].size() == 0)
-      Context.NonAffineAccesses[BasePointer] = AFs();
     Context.NonAffineAccesses[BasePointer].push_back({&Inst, AF});
   } else if (const SCEVAddRecExpr *AF =
                  dyn_cast<SCEVAddRecExpr>(AccessFunction)) {
-    if (Context.AffineAccesses[BasePointer].size() == 0)
-      Context.AffineAccesses[BasePointer] = AFs();
     Context.AffineAccesses[BasePointer].push_back({&Inst, AF});
   }
 





More information about the llvm-commits mailing list