diff options
Diffstat (limited to 'polly/lib/Analysis')
| -rw-r--r-- | polly/lib/Analysis/ScopDetection.cpp | 23 | ||||
| -rw-r--r-- | polly/lib/Analysis/ScopInfo.cpp | 6 |
2 files changed, 19 insertions, 10 deletions
diff --git a/polly/lib/Analysis/ScopDetection.cpp b/polly/lib/Analysis/ScopDetection.cpp index 4776a7f2ab8..47bf54786fb 100644 --- a/polly/lib/Analysis/ScopDetection.cpp +++ b/polly/lib/Analysis/ScopDetection.cpp @@ -716,7 +716,8 @@ ScopDetection::getDelinearizationTerms(DetectionContext &Context, bool ScopDetection::hasValidArraySizes(DetectionContext &Context, SmallVectorImpl<const SCEV *> &Sizes, - const SCEVUnknown *BasePointer) const { + const SCEVUnknown *BasePointer, + Loop *Scope) const { Value *BaseValue = BasePointer->getValue(); Region &CurRegion = Context.CurRegion; for (const SCEV *DelinearizedSize : Sizes) { @@ -733,7 +734,7 @@ bool ScopDetection::hasValidArraySizes(DetectionContext &Context, continue; } } - if (hasScalarDepsInsideRegion(DelinearizedSize, &CurRegion)) + if (hasScalarDepsInsideRegion(DelinearizedSize, &CurRegion, Scope, false)) return invalid<ReportNonAffineAccess>( Context, /*Assert=*/true, DelinearizedSize, Context.Accesses[BasePointer].front().first, BaseValue); @@ -813,8 +814,9 @@ bool ScopDetection::computeAccessFunctions( return true; } -bool ScopDetection::hasBaseAffineAccesses( - DetectionContext &Context, const SCEVUnknown *BasePointer) const { +bool ScopDetection::hasBaseAffineAccesses(DetectionContext &Context, + const SCEVUnknown *BasePointer, + Loop *Scope) const { auto Shape = std::shared_ptr<ArrayShape>(new ArrayShape(BasePointer)); auto Terms = getDelinearizationTerms(Context, BasePointer); @@ -822,7 +824,8 @@ bool ScopDetection::hasBaseAffineAccesses( SE->findArrayDimensions(Terms, Shape->DelinearizedSizes, Context.ElementSize[BasePointer]); - if (!hasValidArraySizes(Context, Shape->DelinearizedSizes, BasePointer)) + if (!hasValidArraySizes(Context, Shape->DelinearizedSizes, BasePointer, + Scope)) return false; return computeAccessFunctions(Context, BasePointer, Shape); @@ -834,13 +837,16 @@ bool ScopDetection::hasAffineMemoryAccesses(DetectionContext &Context) const { if (Context.HasUnknownAccess && !Context.NonAffineAccesses.empty()) return AllowNonAffine; - for (const SCEVUnknown *BasePointer : Context.NonAffineAccesses) - if (!hasBaseAffineAccesses(Context, BasePointer)) { + for (auto &Pair : Context.NonAffineAccesses) { + auto *BasePointer = Pair.first; + auto *Scope = Pair.second; + if (!hasBaseAffineAccesses(Context, BasePointer, Scope)) { if (KeepGoing) continue; else return false; } + } return true; } @@ -901,7 +907,8 @@ bool ScopDetection::isValidAccess(Instruction *Inst, const SCEV *AF, Context.Accesses[BP].push_back({Inst, AF}); if (!IsAffine) - Context.NonAffineAccesses.insert(BP); + Context.NonAffineAccesses.insert( + std::make_pair(BP, LI->getLoopFor(Inst->getParent()))); } else if (!AllowNonAffine && !IsAffine) { return invalid<ReportNonAffineAccess>(Context, /*Assert=*/true, AF, Inst, BV); diff --git a/polly/lib/Analysis/ScopInfo.cpp b/polly/lib/Analysis/ScopInfo.cpp index e5de9c66f4d..135c6fc00a5 100644 --- a/polly/lib/Analysis/ScopInfo.cpp +++ b/polly/lib/Analysis/ScopInfo.cpp @@ -3741,7 +3741,8 @@ void ScopInfo::buildPHIAccesses(PHINode *PHI, Region &R, // If we can synthesize a PHI we can skip it, however only if it is in // the region. If it is not it can only be in the exit block of the region. // In this case we model the operands but not the PHI itself. - if (!IsExitBlock && canSynthesize(PHI, LI, SE, &R)) + auto *Scope = LI->getLoopFor(PHI->getParent()); + if (!IsExitBlock && canSynthesize(PHI, LI, SE, &R, Scope)) return; // PHI nodes are modeled as if they had been demoted prior to the SCoP @@ -4219,7 +4220,8 @@ void ScopInfo::ensureValueRead(Value *V, BasicBlock *UserBB) { // If the instruction can be synthesized and the user is in the region we do // not need to add a value dependences. Region &ScopRegion = scop->getRegion(); - if (canSynthesize(V, LI, SE, &ScopRegion)) + auto *Scope = LI->getLoopFor(UserBB); + if (canSynthesize(V, LI, SE, &ScopRegion, Scope)) return; // Do not build scalar dependences for required invariant loads as we will |

