From: Adam Nemet Date: Thu, 16 Jun 2016 21:55:10 +0000 (+0000) Subject: [LV] Make getSymbolicStrides return a pointer rather than a reference. NFC X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8b651e60d7912f00d968c280b923e4d976ab1961;p=llvm [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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272966 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Vectorize/LoopVectorize.cpp b/lib/Transforms/Vectorize/LoopVectorize.cpp index 2fbd9725dbd..07034249f51 100644 --- a/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -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::isConsecutivePtr(Value *Ptr) { // 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::isConsecutivePtr(Value *Ptr) { // %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(Last)) Last = @@ -4667,7 +4667,7 @@ bool LoopVectorizationLegality::canVectorize() { // 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::collectLoopUniforms() { } bool LoopVectorizationLegality::canVectorizeMemory() { - LAI = &LAA->getInfo(TheLoop, getSymbolicStrides()); + LAI = &LAA->getInfo(TheLoop, *getSymbolicStrides()); auto &OptionalReport = LAI->getReport(); if (OptionalReport) emitAnalysis(VectorizationReport(*OptionalReport));