Remove unnecessary argument of the SCEVValidator [NFC]

llvm-svn: 267400
This commit is contained in:
Johannes Doerfert 2016-04-25 13:32:36 +00:00
parent 3d75f8ce9e
commit ec8a217729
5 changed files with 20 additions and 35 deletions

View File

@ -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.
///

View File

@ -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<const llvm::SCEV *>
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.
///

View File

@ -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<ReportNonAffineAccess>(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<MemIntrinsic>(Inst) && !IsAffine) {
return invalid<ReportNonAffineAccess>(Context, /*Assert=*/true, AF, Inst,

View File

@ -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))

View File

@ -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<Instruction>(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<SCEVCouldNotCompute>(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<SCEVCouldNotCompute>(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<const SCEV *> getParamsInAffineExpr(const Region *R, Loop *Scope,
const SCEV *Expr,
ScalarEvolution &SE,
const Value *BaseAddress) {
ScalarEvolution &SE) {
if (isa<SCEVCouldNotCompute>(Expr))
return std::vector<const SCEV *>();
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!");