Revert "Revert "[SCEV] Add SCEVType to represent vscale
.""
Relanding after fixing Polly related build error. This reverts commit 7b26dcae9eaf8cdcba7fef032fd83d060dffd4b4.
This commit is contained in:
parent
c396073a0d
commit
62d11b2cca
@ -566,6 +566,7 @@ public:
|
|||||||
const SCEV *getLosslessPtrToIntExpr(const SCEV *Op, unsigned Depth = 0);
|
const SCEV *getLosslessPtrToIntExpr(const SCEV *Op, unsigned Depth = 0);
|
||||||
const SCEV *getPtrToIntExpr(const SCEV *Op, Type *Ty);
|
const SCEV *getPtrToIntExpr(const SCEV *Op, Type *Ty);
|
||||||
const SCEV *getTruncateExpr(const SCEV *Op, Type *Ty, unsigned Depth = 0);
|
const SCEV *getTruncateExpr(const SCEV *Op, Type *Ty, unsigned Depth = 0);
|
||||||
|
const SCEV *getVScale(Type *Ty);
|
||||||
const SCEV *getZeroExtendExpr(const SCEV *Op, Type *Ty, unsigned Depth = 0);
|
const SCEV *getZeroExtendExpr(const SCEV *Op, Type *Ty, unsigned Depth = 0);
|
||||||
const SCEV *getZeroExtendExprImpl(const SCEV *Op, Type *Ty,
|
const SCEV *getZeroExtendExprImpl(const SCEV *Op, Type *Ty,
|
||||||
unsigned Depth = 0);
|
unsigned Depth = 0);
|
||||||
|
@ -48,6 +48,8 @@ public:
|
|||||||
|
|
||||||
void visitConstant(const SCEVConstant *Numerator);
|
void visitConstant(const SCEVConstant *Numerator);
|
||||||
|
|
||||||
|
void visitVScale(const SCEVVScale *Numerator);
|
||||||
|
|
||||||
void visitAddRecExpr(const SCEVAddRecExpr *Numerator);
|
void visitAddRecExpr(const SCEVAddRecExpr *Numerator);
|
||||||
|
|
||||||
void visitAddExpr(const SCEVAddExpr *Numerator);
|
void visitAddExpr(const SCEVAddExpr *Numerator);
|
||||||
|
@ -39,6 +39,7 @@ enum SCEVTypes : unsigned short {
|
|||||||
// These should be ordered in terms of increasing complexity to make the
|
// These should be ordered in terms of increasing complexity to make the
|
||||||
// folders simpler.
|
// folders simpler.
|
||||||
scConstant,
|
scConstant,
|
||||||
|
scVScale,
|
||||||
scTruncate,
|
scTruncate,
|
||||||
scZeroExtend,
|
scZeroExtend,
|
||||||
scSignExtend,
|
scSignExtend,
|
||||||
@ -75,6 +76,23 @@ public:
|
|||||||
static bool classof(const SCEV *S) { return S->getSCEVType() == scConstant; }
|
static bool classof(const SCEV *S) { return S->getSCEVType() == scConstant; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// This class represents the value of vscale, as used when defining the length
|
||||||
|
/// of a scalable vector or returned by the llvm.vscale() intrinsic.
|
||||||
|
class SCEVVScale : public SCEV {
|
||||||
|
friend class ScalarEvolution;
|
||||||
|
|
||||||
|
SCEVVScale(const FoldingSetNodeIDRef ID, Type *ty)
|
||||||
|
: SCEV(ID, scVScale, 0), Ty(ty) {}
|
||||||
|
|
||||||
|
Type *Ty;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Type *getType() const { return Ty; }
|
||||||
|
|
||||||
|
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
||||||
|
static bool classof(const SCEV *S) { return S->getSCEVType() == scVScale; }
|
||||||
|
};
|
||||||
|
|
||||||
inline unsigned short computeExpressionSize(ArrayRef<const SCEV *> Args) {
|
inline unsigned short computeExpressionSize(ArrayRef<const SCEV *> Args) {
|
||||||
APInt Size(16, 1);
|
APInt Size(16, 1);
|
||||||
for (const auto *Arg : Args)
|
for (const auto *Arg : Args)
|
||||||
@ -579,9 +597,6 @@ class SCEVUnknown final : public SCEV, private CallbackVH {
|
|||||||
public:
|
public:
|
||||||
Value *getValue() const { return getValPtr(); }
|
Value *getValue() const { return getValPtr(); }
|
||||||
|
|
||||||
/// Check whether this represents vscale.
|
|
||||||
bool isVScale() const;
|
|
||||||
|
|
||||||
Type *getType() const { return getValPtr()->getType(); }
|
Type *getType() const { return getValPtr()->getType(); }
|
||||||
|
|
||||||
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
||||||
@ -595,6 +610,8 @@ template <typename SC, typename RetVal = void> struct SCEVVisitor {
|
|||||||
switch (S->getSCEVType()) {
|
switch (S->getSCEVType()) {
|
||||||
case scConstant:
|
case scConstant:
|
||||||
return ((SC *)this)->visitConstant((const SCEVConstant *)S);
|
return ((SC *)this)->visitConstant((const SCEVConstant *)S);
|
||||||
|
case scVScale:
|
||||||
|
return ((SC *)this)->visitVScale((const SCEVVScale *)S);
|
||||||
case scPtrToInt:
|
case scPtrToInt:
|
||||||
return ((SC *)this)->visitPtrToIntExpr((const SCEVPtrToIntExpr *)S);
|
return ((SC *)this)->visitPtrToIntExpr((const SCEVPtrToIntExpr *)S);
|
||||||
case scTruncate:
|
case scTruncate:
|
||||||
@ -662,6 +679,7 @@ public:
|
|||||||
|
|
||||||
switch (S->getSCEVType()) {
|
switch (S->getSCEVType()) {
|
||||||
case scConstant:
|
case scConstant:
|
||||||
|
case scVScale:
|
||||||
case scUnknown:
|
case scUnknown:
|
||||||
continue;
|
continue;
|
||||||
case scPtrToInt:
|
case scPtrToInt:
|
||||||
@ -751,6 +769,8 @@ public:
|
|||||||
|
|
||||||
const SCEV *visitConstant(const SCEVConstant *Constant) { return Constant; }
|
const SCEV *visitConstant(const SCEVConstant *Constant) { return Constant; }
|
||||||
|
|
||||||
|
const SCEV *visitVScale(const SCEVVScale *VScale) { return VScale; }
|
||||||
|
|
||||||
const SCEV *visitPtrToIntExpr(const SCEVPtrToIntExpr *Expr) {
|
const SCEV *visitPtrToIntExpr(const SCEVPtrToIntExpr *Expr) {
|
||||||
const SCEV *Operand = ((SC *)this)->visit(Expr->getOperand());
|
const SCEV *Operand = ((SC *)this)->visit(Expr->getOperand());
|
||||||
return Operand == Expr->getOperand()
|
return Operand == Expr->getOperand()
|
||||||
|
@ -457,6 +457,8 @@ private:
|
|||||||
|
|
||||||
Value *visitConstant(const SCEVConstant *S) { return S->getValue(); }
|
Value *visitConstant(const SCEVConstant *S) { return S->getValue(); }
|
||||||
|
|
||||||
|
Value *visitVScale(const SCEVVScale *S);
|
||||||
|
|
||||||
Value *visitPtrToIntExpr(const SCEVPtrToIntExpr *S);
|
Value *visitPtrToIntExpr(const SCEVPtrToIntExpr *S);
|
||||||
|
|
||||||
Value *visitTruncateExpr(const SCEVTruncateExpr *S);
|
Value *visitTruncateExpr(const SCEVTruncateExpr *S);
|
||||||
|
@ -271,6 +271,9 @@ void SCEV::print(raw_ostream &OS) const {
|
|||||||
case scConstant:
|
case scConstant:
|
||||||
cast<SCEVConstant>(this)->getValue()->printAsOperand(OS, false);
|
cast<SCEVConstant>(this)->getValue()->printAsOperand(OS, false);
|
||||||
return;
|
return;
|
||||||
|
case scVScale:
|
||||||
|
OS << "vscale";
|
||||||
|
return;
|
||||||
case scPtrToInt: {
|
case scPtrToInt: {
|
||||||
const SCEVPtrToIntExpr *PtrToInt = cast<SCEVPtrToIntExpr>(this);
|
const SCEVPtrToIntExpr *PtrToInt = cast<SCEVPtrToIntExpr>(this);
|
||||||
const SCEV *Op = PtrToInt->getOperand();
|
const SCEV *Op = PtrToInt->getOperand();
|
||||||
@ -366,17 +369,9 @@ void SCEV::print(raw_ostream &OS) const {
|
|||||||
OS << "(" << *UDiv->getLHS() << " /u " << *UDiv->getRHS() << ")";
|
OS << "(" << *UDiv->getLHS() << " /u " << *UDiv->getRHS() << ")";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case scUnknown: {
|
case scUnknown:
|
||||||
const SCEVUnknown *U = cast<SCEVUnknown>(this);
|
cast<SCEVUnknown>(this)->getValue()->printAsOperand(OS, false);
|
||||||
if (U->isVScale()) {
|
|
||||||
OS << "vscale";
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
// Otherwise just print it normally.
|
|
||||||
U->getValue()->printAsOperand(OS, false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
case scCouldNotCompute:
|
case scCouldNotCompute:
|
||||||
OS << "***COULDNOTCOMPUTE***";
|
OS << "***COULDNOTCOMPUTE***";
|
||||||
return;
|
return;
|
||||||
@ -388,6 +383,8 @@ Type *SCEV::getType() const {
|
|||||||
switch (getSCEVType()) {
|
switch (getSCEVType()) {
|
||||||
case scConstant:
|
case scConstant:
|
||||||
return cast<SCEVConstant>(this)->getType();
|
return cast<SCEVConstant>(this)->getType();
|
||||||
|
case scVScale:
|
||||||
|
return cast<SCEVVScale>(this)->getType();
|
||||||
case scPtrToInt:
|
case scPtrToInt:
|
||||||
case scTruncate:
|
case scTruncate:
|
||||||
case scZeroExtend:
|
case scZeroExtend:
|
||||||
@ -419,6 +416,7 @@ Type *SCEV::getType() const {
|
|||||||
ArrayRef<const SCEV *> SCEV::operands() const {
|
ArrayRef<const SCEV *> SCEV::operands() const {
|
||||||
switch (getSCEVType()) {
|
switch (getSCEVType()) {
|
||||||
case scConstant:
|
case scConstant:
|
||||||
|
case scVScale:
|
||||||
case scUnknown:
|
case scUnknown:
|
||||||
return {};
|
return {};
|
||||||
case scPtrToInt:
|
case scPtrToInt:
|
||||||
@ -501,6 +499,18 @@ ScalarEvolution::getConstant(Type *Ty, uint64_t V, bool isSigned) {
|
|||||||
return getConstant(ConstantInt::get(ITy, V, isSigned));
|
return getConstant(ConstantInt::get(ITy, V, isSigned));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const SCEV *ScalarEvolution::getVScale(Type *Ty) {
|
||||||
|
FoldingSetNodeID ID;
|
||||||
|
ID.AddInteger(scVScale);
|
||||||
|
ID.AddPointer(Ty);
|
||||||
|
void *IP = nullptr;
|
||||||
|
if (const SCEV *S = UniqueSCEVs.FindNodeOrInsertPos(ID, IP))
|
||||||
|
return S;
|
||||||
|
SCEV *S = new (SCEVAllocator) SCEVVScale(ID.Intern(SCEVAllocator), Ty);
|
||||||
|
UniqueSCEVs.InsertNode(S, IP);
|
||||||
|
return S;
|
||||||
|
}
|
||||||
|
|
||||||
SCEVCastExpr::SCEVCastExpr(const FoldingSetNodeIDRef ID, SCEVTypes SCEVTy,
|
SCEVCastExpr::SCEVCastExpr(const FoldingSetNodeIDRef ID, SCEVTypes SCEVTy,
|
||||||
const SCEV *op, Type *ty)
|
const SCEV *op, Type *ty)
|
||||||
: SCEV(ID, SCEVTy, computeExpressionSize(op)), Op(op), Ty(ty) {}
|
: SCEV(ID, SCEVTy, computeExpressionSize(op)), Op(op), Ty(ty) {}
|
||||||
@ -560,10 +570,6 @@ void SCEVUnknown::allUsesReplacedWith(Value *New) {
|
|||||||
setValPtr(New);
|
setValPtr(New);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SCEVUnknown::isVScale() const {
|
|
||||||
return match(getValue(), m_VScale());
|
|
||||||
}
|
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// SCEV Utilities
|
// SCEV Utilities
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
@ -714,6 +720,12 @@ CompareSCEVComplexity(EquivalenceClasses<const SCEV *> &EqCacheSCEV,
|
|||||||
return LA.ult(RA) ? -1 : 1;
|
return LA.ult(RA) ? -1 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case scVScale: {
|
||||||
|
const auto *LTy = cast<IntegerType>(cast<SCEVVScale>(LHS)->getType());
|
||||||
|
const auto *RTy = cast<IntegerType>(cast<SCEVVScale>(RHS)->getType());
|
||||||
|
return LTy->getBitWidth() - RTy->getBitWidth();
|
||||||
|
}
|
||||||
|
|
||||||
case scAddRecExpr: {
|
case scAddRecExpr: {
|
||||||
const SCEVAddRecExpr *LA = cast<SCEVAddRecExpr>(LHS);
|
const SCEVAddRecExpr *LA = cast<SCEVAddRecExpr>(LHS);
|
||||||
const SCEVAddRecExpr *RA = cast<SCEVAddRecExpr>(RHS);
|
const SCEVAddRecExpr *RA = cast<SCEVAddRecExpr>(RHS);
|
||||||
@ -4015,6 +4027,8 @@ public:
|
|||||||
|
|
||||||
RetVal visitConstant(const SCEVConstant *Constant) { return Constant; }
|
RetVal visitConstant(const SCEVConstant *Constant) { return Constant; }
|
||||||
|
|
||||||
|
RetVal visitVScale(const SCEVVScale *VScale) { return VScale; }
|
||||||
|
|
||||||
RetVal visitPtrToIntExpr(const SCEVPtrToIntExpr *Expr) { return Expr; }
|
RetVal visitPtrToIntExpr(const SCEVPtrToIntExpr *Expr) { return Expr; }
|
||||||
|
|
||||||
RetVal visitTruncateExpr(const SCEVTruncateExpr *Expr) { return Expr; }
|
RetVal visitTruncateExpr(const SCEVTruncateExpr *Expr) { return Expr; }
|
||||||
@ -4061,6 +4075,7 @@ public:
|
|||||||
static bool scevUnconditionallyPropagatesPoisonFromOperands(SCEVTypes Kind) {
|
static bool scevUnconditionallyPropagatesPoisonFromOperands(SCEVTypes Kind) {
|
||||||
switch (Kind) {
|
switch (Kind) {
|
||||||
case scConstant:
|
case scConstant:
|
||||||
|
case scVScale:
|
||||||
case scTruncate:
|
case scTruncate:
|
||||||
case scZeroExtend:
|
case scZeroExtend:
|
||||||
case scSignExtend:
|
case scSignExtend:
|
||||||
@ -4104,6 +4119,7 @@ static bool impliesPoison(const SCEV *AssumedPoison, const SCEV *S) {
|
|||||||
if (!scevUnconditionallyPropagatesPoisonFromOperands(S->getSCEVType())) {
|
if (!scevUnconditionallyPropagatesPoisonFromOperands(S->getSCEVType())) {
|
||||||
switch (S->getSCEVType()) {
|
switch (S->getSCEVType()) {
|
||||||
case scConstant:
|
case scConstant:
|
||||||
|
case scVScale:
|
||||||
case scTruncate:
|
case scTruncate:
|
||||||
case scZeroExtend:
|
case scZeroExtend:
|
||||||
case scSignExtend:
|
case scSignExtend:
|
||||||
@ -4315,15 +4331,8 @@ const SCEV *ScalarEvolution::getUMinExpr(SmallVectorImpl<const SCEV *> &Ops,
|
|||||||
const SCEV *
|
const SCEV *
|
||||||
ScalarEvolution::getSizeOfExpr(Type *IntTy, TypeSize Size) {
|
ScalarEvolution::getSizeOfExpr(Type *IntTy, TypeSize Size) {
|
||||||
const SCEV *Res = getConstant(IntTy, Size.getKnownMinValue());
|
const SCEV *Res = getConstant(IntTy, Size.getKnownMinValue());
|
||||||
if (Size.isScalable()) {
|
if (Size.isScalable())
|
||||||
// TODO: Why is there no ConstantExpr::getVScale()?
|
Res = getMulExpr(Res, getVScale(IntTy));
|
||||||
Type *SrcElemTy = ScalableVectorType::get(Type::getInt8Ty(getContext()), 1);
|
|
||||||
Constant *NullPtr = Constant::getNullValue(SrcElemTy->getPointerTo());
|
|
||||||
Constant *One = ConstantInt::get(IntTy, 1);
|
|
||||||
Constant *GEP = ConstantExpr::getGetElementPtr(SrcElemTy, NullPtr, One);
|
|
||||||
Constant *VScale = ConstantExpr::getPtrToInt(GEP, IntTy);
|
|
||||||
Res = getMulExpr(Res, getUnknown(VScale));
|
|
||||||
}
|
|
||||||
return Res;
|
return Res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5887,6 +5896,7 @@ static bool IsAvailableOnEntry(const Loop *L, DominatorTree &DT, const SCEV *S,
|
|||||||
bool follow(const SCEV *S) {
|
bool follow(const SCEV *S) {
|
||||||
switch (S->getSCEVType()) {
|
switch (S->getSCEVType()) {
|
||||||
case scConstant:
|
case scConstant:
|
||||||
|
case scVScale:
|
||||||
case scPtrToInt:
|
case scPtrToInt:
|
||||||
case scTruncate:
|
case scTruncate:
|
||||||
case scZeroExtend:
|
case scZeroExtend:
|
||||||
@ -6274,6 +6284,8 @@ uint32_t ScalarEvolution::GetMinTrailingZerosImpl(const SCEV *S) {
|
|||||||
switch (S->getSCEVType()) {
|
switch (S->getSCEVType()) {
|
||||||
case scConstant:
|
case scConstant:
|
||||||
return cast<SCEVConstant>(S)->getAPInt().countr_zero();
|
return cast<SCEVConstant>(S)->getAPInt().countr_zero();
|
||||||
|
case scVScale:
|
||||||
|
return 0;
|
||||||
case scTruncate: {
|
case scTruncate: {
|
||||||
const SCEVTruncateExpr *T = cast<SCEVTruncateExpr>(S);
|
const SCEVTruncateExpr *T = cast<SCEVTruncateExpr>(S);
|
||||||
return std::min(GetMinTrailingZeros(T->getOperand()),
|
return std::min(GetMinTrailingZeros(T->getOperand()),
|
||||||
@ -6504,6 +6516,7 @@ ScalarEvolution::getRangeRefIter(const SCEV *S,
|
|||||||
break;
|
break;
|
||||||
[[fallthrough]];
|
[[fallthrough]];
|
||||||
case scConstant:
|
case scConstant:
|
||||||
|
case scVScale:
|
||||||
case scTruncate:
|
case scTruncate:
|
||||||
case scZeroExtend:
|
case scZeroExtend:
|
||||||
case scSignExtend:
|
case scSignExtend:
|
||||||
@ -6607,6 +6620,8 @@ const ConstantRange &ScalarEvolution::getRangeRef(
|
|||||||
switch (S->getSCEVType()) {
|
switch (S->getSCEVType()) {
|
||||||
case scConstant:
|
case scConstant:
|
||||||
llvm_unreachable("Already handled above.");
|
llvm_unreachable("Already handled above.");
|
||||||
|
case scVScale:
|
||||||
|
return setRange(S, SignHint, std::move(ConservativeResult));
|
||||||
case scTruncate: {
|
case scTruncate: {
|
||||||
const SCEVTruncateExpr *Trunc = cast<SCEVTruncateExpr>(S);
|
const SCEVTruncateExpr *Trunc = cast<SCEVTruncateExpr>(S);
|
||||||
ConstantRange X = getRangeRef(Trunc->getOperand(), SignHint, Depth + 1);
|
ConstantRange X = getRangeRef(Trunc->getOperand(), SignHint, Depth + 1);
|
||||||
@ -9711,6 +9726,7 @@ static Constant *BuildConstantFromSCEV(const SCEV *V) {
|
|||||||
switch (V->getSCEVType()) {
|
switch (V->getSCEVType()) {
|
||||||
case scCouldNotCompute:
|
case scCouldNotCompute:
|
||||||
case scAddRecExpr:
|
case scAddRecExpr:
|
||||||
|
case scVScale:
|
||||||
return nullptr;
|
return nullptr;
|
||||||
case scConstant:
|
case scConstant:
|
||||||
return cast<SCEVConstant>(V)->getValue();
|
return cast<SCEVConstant>(V)->getValue();
|
||||||
@ -9794,6 +9810,7 @@ static Constant *BuildConstantFromSCEV(const SCEV *V) {
|
|||||||
const SCEV *ScalarEvolution::computeSCEVAtScope(const SCEV *V, const Loop *L) {
|
const SCEV *ScalarEvolution::computeSCEVAtScope(const SCEV *V, const Loop *L) {
|
||||||
switch (V->getSCEVType()) {
|
switch (V->getSCEVType()) {
|
||||||
case scConstant:
|
case scConstant:
|
||||||
|
case scVScale:
|
||||||
return V;
|
return V;
|
||||||
case scAddRecExpr: {
|
case scAddRecExpr: {
|
||||||
// If this is a loop recurrence for a loop that does not contain L, then we
|
// If this is a loop recurrence for a loop that does not contain L, then we
|
||||||
@ -9892,6 +9909,7 @@ const SCEV *ScalarEvolution::computeSCEVAtScope(const SCEV *V, const Loop *L) {
|
|||||||
case scSequentialUMinExpr:
|
case scSequentialUMinExpr:
|
||||||
return getSequentialMinMaxExpr(V->getSCEVType(), NewOps);
|
return getSequentialMinMaxExpr(V->getSCEVType(), NewOps);
|
||||||
case scConstant:
|
case scConstant:
|
||||||
|
case scVScale:
|
||||||
case scAddRecExpr:
|
case scAddRecExpr:
|
||||||
case scUnknown:
|
case scUnknown:
|
||||||
case scCouldNotCompute:
|
case scCouldNotCompute:
|
||||||
@ -13677,6 +13695,7 @@ ScalarEvolution::LoopDisposition
|
|||||||
ScalarEvolution::computeLoopDisposition(const SCEV *S, const Loop *L) {
|
ScalarEvolution::computeLoopDisposition(const SCEV *S, const Loop *L) {
|
||||||
switch (S->getSCEVType()) {
|
switch (S->getSCEVType()) {
|
||||||
case scConstant:
|
case scConstant:
|
||||||
|
case scVScale:
|
||||||
return LoopInvariant;
|
return LoopInvariant;
|
||||||
case scAddRecExpr: {
|
case scAddRecExpr: {
|
||||||
const SCEVAddRecExpr *AR = cast<SCEVAddRecExpr>(S);
|
const SCEVAddRecExpr *AR = cast<SCEVAddRecExpr>(S);
|
||||||
@ -13775,6 +13794,7 @@ ScalarEvolution::BlockDisposition
|
|||||||
ScalarEvolution::computeBlockDisposition(const SCEV *S, const BasicBlock *BB) {
|
ScalarEvolution::computeBlockDisposition(const SCEV *S, const BasicBlock *BB) {
|
||||||
switch (S->getSCEVType()) {
|
switch (S->getSCEVType()) {
|
||||||
case scConstant:
|
case scConstant:
|
||||||
|
case scVScale:
|
||||||
return ProperlyDominatesBlock;
|
return ProperlyDominatesBlock;
|
||||||
case scAddRecExpr: {
|
case scAddRecExpr: {
|
||||||
// This uses a "dominates" query instead of "properly dominates" query
|
// This uses a "dominates" query instead of "properly dominates" query
|
||||||
|
@ -126,6 +126,10 @@ void SCEVDivision::visitConstant(const SCEVConstant *Numerator) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SCEVDivision::visitVScale(const SCEVVScale *Numerator) {
|
||||||
|
return cannotDivide(Numerator);
|
||||||
|
}
|
||||||
|
|
||||||
void SCEVDivision::visitAddRecExpr(const SCEVAddRecExpr *Numerator) {
|
void SCEVDivision::visitAddRecExpr(const SCEVAddRecExpr *Numerator) {
|
||||||
const SCEV *StartQ, *StartR, *StepQ, *StepR;
|
const SCEV *StartQ, *StartR, *StepQ, *StepR;
|
||||||
if (!Numerator->isAffine())
|
if (!Numerator->isAffine())
|
||||||
|
@ -976,6 +976,7 @@ static bool isHighCostExpansion(const SCEV *S,
|
|||||||
switch (S->getSCEVType()) {
|
switch (S->getSCEVType()) {
|
||||||
case scUnknown:
|
case scUnknown:
|
||||||
case scConstant:
|
case scConstant:
|
||||||
|
case scVScale:
|
||||||
return false;
|
return false;
|
||||||
case scTruncate:
|
case scTruncate:
|
||||||
return isHighCostExpansion(cast<SCEVTruncateExpr>(S)->getOperand(),
|
return isHighCostExpansion(cast<SCEVTruncateExpr>(S)->getOperand(),
|
||||||
@ -2812,9 +2813,10 @@ static bool isCompatibleIVType(Value *LVal, Value *RVal) {
|
|||||||
/// SCEVUnknown, we simply return the rightmost SCEV operand.
|
/// SCEVUnknown, we simply return the rightmost SCEV operand.
|
||||||
static const SCEV *getExprBase(const SCEV *S) {
|
static const SCEV *getExprBase(const SCEV *S) {
|
||||||
switch (S->getSCEVType()) {
|
switch (S->getSCEVType()) {
|
||||||
default: // uncluding scUnknown.
|
default: // including scUnknown.
|
||||||
return S;
|
return S;
|
||||||
case scConstant:
|
case scConstant:
|
||||||
|
case scVScale:
|
||||||
return nullptr;
|
return nullptr;
|
||||||
case scTruncate:
|
case scTruncate:
|
||||||
return getExprBase(cast<SCEVTruncateExpr>(S)->getOperand());
|
return getExprBase(cast<SCEVTruncateExpr>(S)->getOperand());
|
||||||
|
@ -680,6 +680,7 @@ const Loop *SCEVExpander::getRelevantLoop(const SCEV *S) {
|
|||||||
|
|
||||||
switch (S->getSCEVType()) {
|
switch (S->getSCEVType()) {
|
||||||
case scConstant:
|
case scConstant:
|
||||||
|
case scVScale:
|
||||||
return nullptr; // A constant has no relevant loops.
|
return nullptr; // A constant has no relevant loops.
|
||||||
case scTruncate:
|
case scTruncate:
|
||||||
case scZeroExtend:
|
case scZeroExtend:
|
||||||
@ -1744,6 +1745,10 @@ Value *SCEVExpander::visitSequentialUMinExpr(const SCEVSequentialUMinExpr *S) {
|
|||||||
return expandMinMaxExpr(S, Intrinsic::umin, "umin", /*IsSequential*/true);
|
return expandMinMaxExpr(S, Intrinsic::umin, "umin", /*IsSequential*/true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Value *SCEVExpander::visitVScale(const SCEVVScale *S) {
|
||||||
|
return Builder.CreateVScale(ConstantInt::get(S->getType(), 1));
|
||||||
|
}
|
||||||
|
|
||||||
Value *SCEVExpander::expandCodeForImpl(const SCEV *SH, Type *Ty,
|
Value *SCEVExpander::expandCodeForImpl(const SCEV *SH, Type *Ty,
|
||||||
Instruction *IP) {
|
Instruction *IP) {
|
||||||
setInsertPoint(IP);
|
setInsertPoint(IP);
|
||||||
@ -2124,6 +2129,7 @@ template<typename T> static InstructionCost costAndCollectOperands(
|
|||||||
llvm_unreachable("Attempt to use a SCEVCouldNotCompute object!");
|
llvm_unreachable("Attempt to use a SCEVCouldNotCompute object!");
|
||||||
case scUnknown:
|
case scUnknown:
|
||||||
case scConstant:
|
case scConstant:
|
||||||
|
case scVScale:
|
||||||
return 0;
|
return 0;
|
||||||
case scPtrToInt:
|
case scPtrToInt:
|
||||||
Cost = CastCost(Instruction::PtrToInt);
|
Cost = CastCost(Instruction::PtrToInt);
|
||||||
@ -2260,6 +2266,7 @@ bool SCEVExpander::isHighCostExpansionHelper(
|
|||||||
case scCouldNotCompute:
|
case scCouldNotCompute:
|
||||||
llvm_unreachable("Attempt to use a SCEVCouldNotCompute object!");
|
llvm_unreachable("Attempt to use a SCEVCouldNotCompute object!");
|
||||||
case scUnknown:
|
case scUnknown:
|
||||||
|
case scVScale:
|
||||||
// Assume to be zero-cost.
|
// Assume to be zero-cost.
|
||||||
return false;
|
return false;
|
||||||
case scConstant: {
|
case scConstant: {
|
||||||
|
@ -99,6 +99,7 @@ private:
|
|||||||
|
|
||||||
PWACtx visit(const llvm::SCEV *E);
|
PWACtx visit(const llvm::SCEV *E);
|
||||||
PWACtx visitConstant(const llvm::SCEVConstant *E);
|
PWACtx visitConstant(const llvm::SCEVConstant *E);
|
||||||
|
PWACtx visitVScale(const llvm::SCEVVScale *E);
|
||||||
PWACtx visitPtrToIntExpr(const llvm::SCEVPtrToIntExpr *E);
|
PWACtx visitPtrToIntExpr(const llvm::SCEVPtrToIntExpr *E);
|
||||||
PWACtx visitTruncateExpr(const llvm::SCEVTruncateExpr *E);
|
PWACtx visitTruncateExpr(const llvm::SCEVTruncateExpr *E);
|
||||||
PWACtx visitZeroExtendExpr(const llvm::SCEVZeroExtendExpr *E);
|
PWACtx visitZeroExtendExpr(const llvm::SCEVZeroExtendExpr *E);
|
||||||
|
@ -266,6 +266,10 @@ PWACtx SCEVAffinator::visitConstant(const SCEVConstant *Expr) {
|
|||||||
isl::manage(isl_pw_aff_from_aff(isl_aff_val_on_domain(ls, v))));
|
isl::manage(isl_pw_aff_from_aff(isl_aff_val_on_domain(ls, v))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PWACtx SCEVAffinator::visitVScale(const SCEVVScale *VScale) {
|
||||||
|
llvm_unreachable("SCEVVScale not yet supported");
|
||||||
|
}
|
||||||
|
|
||||||
PWACtx SCEVAffinator::visitPtrToIntExpr(const SCEVPtrToIntExpr *Expr) {
|
PWACtx SCEVAffinator::visitPtrToIntExpr(const SCEVPtrToIntExpr *Expr) {
|
||||||
return visit(Expr->getOperand(0));
|
return visit(Expr->getOperand(0));
|
||||||
}
|
}
|
||||||
|
@ -134,6 +134,12 @@ public:
|
|||||||
return ValidatorResult(SCEVType::INT);
|
return ValidatorResult(SCEVType::INT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ValidatorResult visitVScale(const SCEVVScale *VScale) {
|
||||||
|
// We do not support VScale constants.
|
||||||
|
LLVM_DEBUG(dbgs() << "INVALID: VScale is not supported");
|
||||||
|
return ValidatorResult(SCEVType::INVALID);
|
||||||
|
}
|
||||||
|
|
||||||
ValidatorResult visitZeroExtendOrTruncateExpr(const SCEV *Expr,
|
ValidatorResult visitZeroExtendOrTruncateExpr(const SCEV *Expr,
|
||||||
const SCEV *Operand) {
|
const SCEV *Operand) {
|
||||||
ValidatorResult Op = visit(Operand);
|
ValidatorResult Op = visit(Operand);
|
||||||
|
@ -338,6 +338,7 @@ private:
|
|||||||
///
|
///
|
||||||
///{
|
///{
|
||||||
const SCEV *visitConstant(const SCEVConstant *E) { return E; }
|
const SCEV *visitConstant(const SCEVConstant *E) { return E; }
|
||||||
|
const SCEV *visitVScale(const SCEVVScale *E) { return E; }
|
||||||
const SCEV *visitPtrToIntExpr(const SCEVPtrToIntExpr *E) {
|
const SCEV *visitPtrToIntExpr(const SCEVPtrToIntExpr *E) {
|
||||||
return SE.getPtrToIntExpr(visit(E->getOperand()), E->getType());
|
return SE.getPtrToIntExpr(visit(E->getOperand()), E->getType());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user