[llvm] r272966 - [LV] Make getSymbolicStrides return a pointer rather than a reference. NFC

Adam Nemet via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 16 14:55:10 PDT 2016


Author: anemet
Date: Thu Jun 16 16:55:10 2016
New Revision: 272966

URL: http://llvm.org/viewvc/llvm-project?rev=272966&view=rev
Log:
[LV] Make getSymbolicStrides return a pointer rather than a reference. NFC

Turns out SymbolicStrides is actually used in canVectorizeWithIfConvert
before it gets set up in canVectorizeMemory.

This works fine as long as SymbolicStrides resides in LV since we just
have an empty map.  Based on this the conclusion is made that there are
no symbolic strides which is conservatively correct.

However once SymbolicStrides becomes part of LAI, LAI is nullptr at this
point so we need to differentiate the uninitialized state by returning a
nullptr for SymbolicStrides.

Modified:
    llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp

Modified: llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp?rev=272966&r1=272965&r2=272966&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp (original)
+++ llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp Thu Jun 16 16:55:10 2016
@@ -1450,7 +1450,7 @@ private:
 
   /// \brief If an access has a symbolic strides, this maps the pointer value to
   /// the stride symbol.
-  const ValueToValueMap &getSymbolicStrides() { return SymbolicStrides; }
+  const ValueToValueMap *getSymbolicStrides() { return &SymbolicStrides; }
 
   unsigned NumPredStores;
 
@@ -2224,7 +2224,7 @@ int LoopVectorizationLegality::isConsecu
   // We can emit wide load/stores only if the last non-zero index is the
   // induction variable.
   const SCEV *Last = nullptr;
-  if (!getSymbolicStrides().count(Gep))
+  if (!getSymbolicStrides() || !getSymbolicStrides()->count(Gep))
     Last = PSE.getSCEV(Gep->getOperand(InductionOperand));
   else {
     // Because of the multiplication by a stride we can have a s/zext cast.
@@ -2236,7 +2236,7 @@ int LoopVectorizationLegality::isConsecu
     //  %idxprom = zext i32 %mul to i64  << Safe cast.
     //  %arrayidx = getelementptr inbounds i32* %B, i64 %idxprom
     //
-    Last = replaceSymbolicStrideSCEV(PSE, getSymbolicStrides(),
+    Last = replaceSymbolicStrideSCEV(PSE, *getSymbolicStrides(),
                                      Gep->getOperand(InductionOperand), Gep);
     if (const SCEVCastExpr *C = dyn_cast<SCEVCastExpr>(Last))
       Last =
@@ -4667,7 +4667,7 @@ bool LoopVectorizationLegality::canVecto
 
   // Analyze interleaved memory accesses.
   if (UseInterleaved)
-    InterleaveInfo.analyzeInterleaving(getSymbolicStrides());
+    InterleaveInfo.analyzeInterleaving(*getSymbolicStrides());
 
   unsigned SCEVThreshold = VectorizeSCEVCheckThreshold;
   if (Hints->getForce() == LoopVectorizeHints::FK_Enabled)
@@ -4998,7 +4998,7 @@ void LoopVectorizationLegality::collectL
 }
 
 bool LoopVectorizationLegality::canVectorizeMemory() {
-  LAI = &LAA->getInfo(TheLoop, getSymbolicStrides());
+  LAI = &LAA->getInfo(TheLoop, *getSymbolicStrides());
   auto &OptionalReport = LAI->getReport();
   if (OptionalReport)
     emitAnalysis(VectorizationReport(*OptionalReport));




More information about the llvm-commits mailing list