Please use GitHub pull requests for new patches. Avoid migrating existing patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
lib/Support/SCEVValidator.cpp
Show First 20 Lines • Show All 150 Lines • ▼ Show 20 Lines | class ValidatorResult visitTruncateExpr(const SCEVTruncateExpr *Expr) { | ||||
case SCEVType::INVALID: | case SCEVType::INVALID: | ||||
return Op; | return Op; | ||||
} | } | ||||
llvm_unreachable("Unknown SCEVType"); | llvm_unreachable("Unknown SCEVType"); | ||||
} | } | ||||
class ValidatorResult visitZeroExtendExpr(const SCEVZeroExtendExpr *Expr) { | class ValidatorResult visitZeroExtendExpr(const SCEVZeroExtendExpr *Expr) { | ||||
ValidatorResult Op = visit(Expr->getOperand()); | const SCEV *OpS = Expr->getOperand(); | ||||
ValidatorResult Op = visit(OpS); | |||||
// Explicitly check for expressions of the following form: | |||||
// i % 2^C | |||||
// which could either be a srem (%) expressions or an and (&) expressions. | |||||
// The srem (%) versions are caught by visitUnknown, the and (&) versions | |||||
// are expressed as | |||||
// zext iC {0,+,1}<%for_i> | |||||
// by scalar evolution. | |||||
if (auto *OpAR = dyn_cast<SCEVAddRecExpr>(OpS)) | |||||
if (OpAR->getStart()->isZero() && OpAR->getStepRecurrence(SE)->isOne()) | |||||
return Op; | |||||
switch (Op.getType()) { | switch (Op.getType()) { | ||||
simbuerg: capture | |||||
case SCEVType::INT: | case SCEVType::INT: | ||||
case SCEVType::PARAM: | case SCEVType::PARAM: | ||||
// We currently do not represent a truncate expression as an affine | // We currently do not represent a truncate expression as an affine | ||||
// expression. If it is constant during Scop execution, we treat it as a | // expression. If it is constant during Scop execution, we treat it as a | ||||
// parameter. | // parameter. | ||||
return ValidatorResult(SCEVType::PARAM, Expr); | return ValidatorResult(SCEVType::PARAM, Expr); | ||||
case SCEVType::IV: | case SCEVType::IV: | ||||
DEBUG(dbgs() << "INVALID: ZeroExtend of SCEVType::IV expression"); | DEBUG(dbgs() << "INVALID: ZeroExtend of SCEVType::IV expression"); | ||||
return ValidatorResult(SCEVType::INVALID); | return ValidatorResult(SCEVType::INVALID); | ||||
case SCEVType::INVALID: | case SCEVType::INVALID: | ||||
return Op; | return Op; | ||||
Not Done ReplyInline ActionsI would use the type here. simbuerg: I would use the type here. | |||||
} | } | ||||
llvm_unreachable("Unknown SCEVType"); | llvm_unreachable("Unknown SCEVType"); | ||||
} | } | ||||
class ValidatorResult visitSignExtendExpr(const SCEVSignExtendExpr *Expr) { | class ValidatorResult visitSignExtendExpr(const SCEVSignExtendExpr *Expr) { | ||||
// We currently allow only signed SCEV expressions. In the case of a | // We currently allow only signed SCEV expressions. In the case of a | ||||
// signed value, a sign extend is a noop. | // signed value, a sign extend is a noop. | ||||
▲ Show 20 Lines • Show All 160 Lines • ▼ Show 20 Lines | if (!Expr->getType()->isIntegerTy()) { | ||||
return ValidatorResult(SCEVType::INVALID); | return ValidatorResult(SCEVType::INVALID); | ||||
} | } | ||||
if (isa<UndefValue>(V)) { | if (isa<UndefValue>(V)) { | ||||
DEBUG(dbgs() << "INVALID: UnknownExpr references an undef value"); | DEBUG(dbgs() << "INVALID: UnknownExpr references an undef value"); | ||||
return ValidatorResult(SCEVType::INVALID); | return ValidatorResult(SCEVType::INVALID); | ||||
} | } | ||||
if (Instruction *I = dyn_cast<Instruction>(Expr->getValue())) | if (Instruction *I = dyn_cast<Instruction>(Expr->getValue())) { | ||||
if (I->getOpcode() == Instruction::SRem) { | |||||
ValidatorResult Op0 = visit(SE.getSCEV(I->getOperand(0))); | |||||
if (!Op0.isValid()) | |||||
return ValidatorResult(SCEVType::INVALID); | |||||
ValidatorResult Op1 = visit(SE.getSCEV(I->getOperand(1))); | |||||
if (!Op1.isValid() || !Op1.isINT()) | |||||
return ValidatorResult(SCEVType::INVALID); | |||||
Op0.merge(Op1); | |||||
return Op0; | |||||
} | |||||
Not Done ReplyInline ActionsConsistency: auto? simbuerg: Consistency: auto? | |||||
if (R->contains(I)) { | if (R->contains(I)) { | ||||
DEBUG(dbgs() << "INVALID: UnknownExpr references an instruction " | DEBUG(dbgs() << "INVALID: UnknownExpr references an instruction " | ||||
"within the region\n"); | "within the region\n"); | ||||
return ValidatorResult(SCEVType::INVALID); | return ValidatorResult(SCEVType::INVALID); | ||||
} | } | ||||
} | |||||
if (BaseAddress == V) { | if (BaseAddress == V) { | ||||
DEBUG(dbgs() << "INVALID: UnknownExpr references BaseAddress\n"); | DEBUG(dbgs() << "INVALID: UnknownExpr references BaseAddress\n"); | ||||
return ValidatorResult(SCEVType::INVALID); | return ValidatorResult(SCEVType::INVALID); | ||||
} | } | ||||
return ValidatorResult(SCEVType::PARAM, Expr); | return ValidatorResult(SCEVType::PARAM, Expr); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 134 Lines • Show Last 20 Lines |
capture