From ec8a2177298d38129e9a28ff0fd79afa464f42a9 Mon Sep 17 00:00:00 2001 From: Johannes Doerfert Date: Mon, 25 Apr 2016 13:32:36 +0000 Subject: [PATCH] Remove unnecessary argument of the SCEVValidator [NFC] llvm-svn: 267400 --- polly/include/polly/ScopDetection.h | 4 +--- polly/include/polly/Support/SCEVValidator.h | 4 +--- polly/lib/Analysis/ScopDetection.cpp | 15 +++++++------- polly/lib/Analysis/ScopInfo.cpp | 10 ++++------ polly/lib/Support/SCEVValidator.cpp | 22 +++++++-------------- 5 files changed, 20 insertions(+), 35 deletions(-) diff --git a/polly/include/polly/ScopDetection.h b/polly/include/polly/ScopDetection.h index d033a98f01e9..c029df40fa66 100644 --- a/polly/include/polly/ScopDetection.h +++ b/polly/include/polly/ScopDetection.h @@ -440,9 +440,7 @@ private: /// @param S The expression to be checked. /// @param Scope The loop nest in which @p S is used. /// @param Context The context of scop detection. - /// @param BaseAddress The base address of the expression @p S (if any). - bool isAffine(const SCEV *S, Loop *Scope, DetectionContext &Context, - Value *BaseAddress = nullptr) const; + bool isAffine(const SCEV *S, Loop *Scope, DetectionContext &Context) const; /// @brief Check if the control flow in a basic block is valid. /// diff --git a/polly/include/polly/Support/SCEVValidator.h b/polly/include/polly/Support/SCEVValidator.h index b95c667dd55e..8b882e3d2263 100644 --- a/polly/include/polly/Support/SCEVValidator.h +++ b/polly/include/polly/Support/SCEVValidator.h @@ -55,7 +55,6 @@ bool hasScalarDepsInsideRegion(const llvm::SCEV *S, const llvm::Region *R, llvm::Loop *Scope, bool AllowLoops); bool isAffineExpr(const llvm::Region *R, llvm::Loop *Scope, const llvm::SCEV *Expression, llvm::ScalarEvolution &SE, - const llvm::Value *BaseAddress = 0, InvariantLoadsSetTy *ILS = nullptr); /// @brief Check if @p V describes an affine parameter constraint in @p R. @@ -66,8 +65,7 @@ bool isAffineParamConstraint(llvm::Value *V, const llvm::Region *R, std::vector getParamsInAffineExpr(const llvm::Region *R, llvm::Loop *Scope, - const llvm::SCEV *Expression, llvm::ScalarEvolution &SE, - const llvm::Value *BaseAddress = 0); + const llvm::SCEV *Expression, llvm::ScalarEvolution &SE); /// @brief Extract the constant factors from the multiplication @p M. /// diff --git a/polly/lib/Analysis/ScopDetection.cpp b/polly/lib/Analysis/ScopDetection.cpp index e5914df44f12..c6676ff1dd93 100644 --- a/polly/lib/Analysis/ScopDetection.cpp +++ b/polly/lib/Analysis/ScopDetection.cpp @@ -330,11 +330,10 @@ bool ScopDetection::onlyValidRequiredInvariantLoads( } bool ScopDetection::isAffine(const SCEV *S, Loop *Scope, - DetectionContext &Context, - Value *BaseAddress) const { + DetectionContext &Context) const { InvariantLoadsSetTy AccessILS; - if (!isAffineExpr(&Context.CurRegion, Scope, S, *SE, BaseAddress, &AccessILS)) + if (!isAffineExpr(&Context.CurRegion, Scope, S, *SE, &AccessILS)) return false; if (!onlyValidRequiredInvariantLoads(AccessILS, Context)) @@ -731,7 +730,7 @@ bool ScopDetection::hasValidArraySizes(DetectionContext &Context, Value *BaseValue = BasePointer->getValue(); Region &CurRegion = Context.CurRegion; for (const SCEV *DelinearizedSize : Sizes) { - if (!isAffine(DelinearizedSize, Scope, Context, nullptr)) { + if (!isAffine(DelinearizedSize, Scope, Context)) { Sizes.clear(); break; } @@ -759,7 +758,7 @@ bool ScopDetection::hasValidArraySizes(DetectionContext &Context, const Instruction *Insn = Pair.first; const SCEV *AF = Pair.second; - if (!isAffine(AF, Scope, Context, BaseValue)) { + if (!isAffine(AF, Scope, Context)) { invalid(Context, /*Assert=*/true, AF, Insn, BaseValue); if (!KeepGoing) @@ -793,7 +792,7 @@ bool ScopDetection::computeAccessFunctions( auto *Scope = LI->getLoopFor(Insn->getParent()); if (!AF) { - if (isAffine(Pair.second, Scope, Context, BaseValue)) + if (isAffine(Pair.second, Scope, Context)) Acc->DelinearizedSubscripts.push_back(Pair.second); else IsNonAffine = true; @@ -803,7 +802,7 @@ bool ScopDetection::computeAccessFunctions( if (Acc->DelinearizedSubscripts.size() == 0) IsNonAffine = true; for (const SCEV *S : Acc->DelinearizedSubscripts) - if (!isAffine(S, Scope, Context, BaseValue)) + if (!isAffine(S, Scope, Context)) IsNonAffine = true; } @@ -910,7 +909,7 @@ bool ScopDetection::isValidAccess(Instruction *Inst, const SCEV *AF, IsVariantInNonAffineLoop = true; auto *Scope = LI->getLoopFor(Inst->getParent()); - bool IsAffine = !IsVariantInNonAffineLoop && isAffine(AF, Scope, Context, BV); + bool IsAffine = !IsVariantInNonAffineLoop && isAffine(AF, Scope, Context); // Do not try to delinearize memory intrinsics and force them to be affine. if (isa(Inst) && !IsAffine) { return invalid(Context, /*Assert=*/true, AF, Inst, diff --git a/polly/lib/Analysis/ScopInfo.cpp b/polly/lib/Analysis/ScopInfo.cpp index d625d41c5199..9d34a730fe1f 100644 --- a/polly/lib/Analysis/ScopInfo.cpp +++ b/polly/lib/Analysis/ScopInfo.cpp @@ -1405,8 +1405,7 @@ void ScopStmt::deriveAssumptionsFromGEP(GetElementPtrInst *GEP, auto *Scope = SD.getLI()->getLoopFor(getEntryBlock()); InvariantLoadsSetTy AccessILS; - if (!isAffineExpr(&Parent.getRegion(), Scope, Expr, SE, nullptr, - &AccessILS)) + if (!isAffineExpr(&Parent.getRegion(), Scope, Expr, SE, &AccessILS)) continue; bool NonAffine = false; @@ -4234,7 +4233,7 @@ bool ScopInfo::buildAccessMultiDimFixed( for (auto *Subscript : Subscripts) { InvariantLoadsSetTy AccessILS; - if (!isAffineExpr(R, L, Subscript, *SE, nullptr, &AccessILS)) + if (!isAffineExpr(R, L, Subscript, *SE, &AccessILS)) return false; for (LoadInst *LInst : AccessILS) @@ -4313,7 +4312,7 @@ bool ScopInfo::buildAccessMemIntrinsic( // Check if the length val is actually affine or if we overapproximate it InvariantLoadsSetTy AccessILS; - bool LengthIsAffine = isAffineExpr(R, L, LengthVal, *SE, nullptr, &AccessILS); + bool LengthIsAffine = isAffineExpr(R, L, LengthVal, *SE, &AccessILS); for (LoadInst *LInst : AccessILS) if (!ScopRIL.count(LInst)) LengthIsAffine = false; @@ -4439,8 +4438,7 @@ void ScopInfo::buildAccessSingleDim( InvariantLoadsSetTy AccessILS; bool IsAffine = !isVariantInNonAffineLoop && - isAffineExpr(R, L, AccessFunction, *SE, - BasePointer->getValue(), &AccessILS); + isAffineExpr(R, L, AccessFunction, *SE, &AccessILS); for (LoadInst *LInst : AccessILS) if (!ScopRIL.count(LInst)) diff --git a/polly/lib/Support/SCEVValidator.cpp b/polly/lib/Support/SCEVValidator.cpp index a9d7ebf6562c..390a4f5d4060 100644 --- a/polly/lib/Support/SCEVValidator.cpp +++ b/polly/lib/Support/SCEVValidator.cpp @@ -126,13 +126,12 @@ private: const Region *R; Loop *Scope; ScalarEvolution &SE; - const Value *BaseAddress; InvariantLoadsSetTy *ILS; public: SCEVValidator(const Region *R, Loop *Scope, ScalarEvolution &SE, - const Value *BaseAddress, InvariantLoadsSetTy *ILS) - : R(R), Scope(Scope), SE(SE), BaseAddress(BaseAddress), ILS(ILS) {} + InvariantLoadsSetTy *ILS) + : R(R), Scope(Scope), SE(SE), ILS(ILS) {} class ValidatorResult visitConstant(const SCEVConstant *Constant) { return ValidatorResult(SCEVType::INT); @@ -396,11 +395,6 @@ public: return ValidatorResult(SCEVType::INVALID); } - if (BaseAddress == V) { - DEBUG(dbgs() << "INVALID: UnknownExpr references BaseAddress\n"); - return ValidatorResult(SCEVType::INVALID); - } - if (Instruction *I = dyn_cast(Expr->getValue())) { switch (I->getOpcode()) { case Instruction::Load: @@ -530,12 +524,11 @@ bool hasScalarDepsInsideRegion(const SCEV *Expr, const Region *R, } bool isAffineExpr(const Region *R, llvm::Loop *Scope, const SCEV *Expr, - ScalarEvolution &SE, const Value *BaseAddress, - InvariantLoadsSetTy *ILS) { + ScalarEvolution &SE, InvariantLoadsSetTy *ILS) { if (isa(Expr)) return false; - SCEVValidator Validator(R, Scope, SE, BaseAddress, ILS); + SCEVValidator Validator(R, Scope, SE, ILS); DEBUG({ dbgs() << "\n"; dbgs() << "Expr: " << *Expr << "\n"; @@ -561,7 +554,7 @@ static bool isAffineParamExpr(Value *V, const Region *R, Loop *Scope, if (isa(E)) return false; - SCEVValidator Validator(R, Scope, SE, nullptr, nullptr); + SCEVValidator Validator(R, Scope, SE, nullptr); ValidatorResult Result = Validator.visit(E); if (!Result.isConstant()) return false; @@ -598,13 +591,12 @@ bool isAffineParamConstraint(Value *V, const Region *R, llvm::Loop *Scope, std::vector getParamsInAffineExpr(const Region *R, Loop *Scope, const SCEV *Expr, - ScalarEvolution &SE, - const Value *BaseAddress) { + ScalarEvolution &SE) { if (isa(Expr)) return std::vector(); InvariantLoadsSetTy ILS; - SCEVValidator Validator(R, Scope, SE, BaseAddress, &ILS); + SCEVValidator Validator(R, Scope, SE, &ILS); ValidatorResult Result = Validator.visit(Expr); assert(Result.isValid() && "Requested parameters for an invalid SCEV!");