Skip to content

Commit

Permalink
[SVE] Remove calls to VectorType::isScalable from analysis
Browse files Browse the repository at this point in the history
Reviewers: efriedma, sdesmalen, chandlerc, sunfish

Reviewed By: efriedma

Subscribers: tschuett, hiraditya, rkruppe, psnobl, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D77692
  • Loading branch information
christetreault-llvm committed Apr 23, 2020
1 parent 156afb2 commit 9174e02
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 26 deletions.
3 changes: 1 addition & 2 deletions llvm/lib/Analysis/BasicAliasAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,8 +533,7 @@ bool BasicAAResult::DecomposeGEPExpression(const Value *V,

// Don't attempt to analyze GEPs if index scale is not a compile-time
// constant.
Type *SrcEleTy = GEPOp->getSourceElementType();
if (SrcEleTy->isVectorTy() && cast<VectorType>(SrcEleTy)->isScalable()) {
if (isa<ScalableVectorType>(GEPOp->getSourceElementType())) {
Decomposed.Base = V;
Decomposed.HasCompileTimeConstantScale = false;
return false;
Expand Down
7 changes: 3 additions & 4 deletions llvm/lib/Analysis/ConstantFolding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ bool ReadDataFromGlobal(Constant *C, uint64_t ByteOffset, unsigned char *CurPtr,
Constant *FoldReinterpretLoadFromConstPtr(Constant *C, Type *LoadTy,
const DataLayout &DL) {
// Bail out early. Not expect to load from scalable global variable.
if (LoadTy->isVectorTy() && cast<VectorType>(LoadTy)->isScalable())
if (isa<ScalableVectorType>(LoadTy))
return nullptr;

auto *PTy = cast<PointerType>(C->getType());
Expand Down Expand Up @@ -836,8 +836,7 @@ Constant *SymbolicallyEvaluateGEP(const GEPOperator *GEP,
Type *SrcElemTy = GEP->getSourceElementType();
Type *ResElemTy = GEP->getResultElementType();
Type *ResTy = GEP->getType();
if (!SrcElemTy->isSized() ||
(SrcElemTy->isVectorTy() && cast<VectorType>(SrcElemTy)->isScalable()))
if (!SrcElemTy->isSized() || isa<ScalableVectorType>(SrcElemTy))
return nullptr;

if (Constant *C = CastGEPIndices(SrcElemTy, Ops, ResTy,
Expand Down Expand Up @@ -2572,7 +2571,7 @@ static Constant *ConstantFoldVectorCall(StringRef Name,

// Do not iterate on scalable vector. The number of elements is unknown at
// compile-time.
if (VTy->isScalable())
if (isa<ScalableVectorType>(VTy))
return nullptr;

if (IntrinsicID == Intrinsic::masked_load) {
Expand Down
10 changes: 5 additions & 5 deletions llvm/lib/Analysis/InstructionSimplify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4151,8 +4151,7 @@ static Value *SimplifyGEPInst(Type *SrcTy, ArrayRef<Value *> Ops,
if (isa<UndefValue>(Ops[0]))
return UndefValue::get(GEPTy);

bool IsScalableVec =
isa<VectorType>(SrcTy) && cast<VectorType>(SrcTy)->isScalable();
bool IsScalableVec = isa<ScalableVectorType>(SrcTy);

if (Ops.size() == 2) {
// getelementptr P, 0 -> P.
Expand Down Expand Up @@ -4294,8 +4293,8 @@ Value *llvm::SimplifyInsertElementInst(Value *Vec, Value *Val, Value *Idx,

// For fixed-length vector, fold into undef if index is out of bounds.
if (auto *CI = dyn_cast<ConstantInt>(Idx)) {
if (!cast<VectorType>(Vec->getType())->isScalable() &&
CI->uge(cast<VectorType>(Vec->getType())->getNumElements()))
if (isa<FixedVectorType>(Vec->getType()) &&
CI->uge(cast<FixedVectorType>(Vec->getType())->getNumElements()))
return UndefValue::get(Vec->getType());
}

Expand Down Expand Up @@ -4368,7 +4367,8 @@ static Value *SimplifyExtractElementInst(Value *Vec, Value *Idx, const SimplifyQ
// find a previously computed scalar that was inserted into the vector.
if (auto *IdxC = dyn_cast<ConstantInt>(Idx)) {
// For fixed-length vector, fold into undef if index is out of bounds.
if (!VecVTy->isScalable() && IdxC->getValue().uge(VecVTy->getNumElements()))
if (isa<FixedVectorType>(VecVTy) &&
IdxC->getValue().uge(VecVTy->getNumElements()))
return UndefValue::get(VecVTy->getElementType());
if (Value *Elt = findScalarElement(Vec, IdxC->getZExtValue()))
return Elt;
Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/Analysis/Loads.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,7 @@ bool llvm::isDereferenceableAndAlignedPointer(const Value *V, Type *Ty,
const DominatorTree *DT) {
// For unsized types or scalable vectors we don't know exactly how many bytes
// are dereferenced, so bail out.
if (!Ty->isSized() ||
(Ty->isVectorTy() && cast<VectorType>(Ty)->isScalable()))
if (!Ty->isSized() || isa<ScalableVectorType>(Ty))
return false;

// When dereferenceability information is provided by a dereferenceable
Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/Analysis/MemoryBuiltins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -650,8 +650,7 @@ SizeOffsetType ObjectSizeOffsetVisitor::visitAllocaInst(AllocaInst &I) {
if (!I.getAllocatedType()->isSized())
return unknown();

if (I.getAllocatedType()->isVectorTy() &&
cast<VectorType>(I.getAllocatedType())->isScalable())
if (isa<ScalableVectorType>(I.getAllocatedType()))
return unknown();

APInt Size(IntTyBits, DL.getTypeAllocSize(I.getAllocatedType()));
Expand Down
12 changes: 5 additions & 7 deletions llvm/lib/Analysis/ScalarEvolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3759,13 +3759,11 @@ const SCEV *ScalarEvolution::getSizeOfExpr(Type *IntTy, Type *AllocTy) {
// We can bypass creating a target-independent
// constant expression and then folding it back into a ConstantInt.
// This is just a compile-time optimization.
if (auto *VecTy = dyn_cast<VectorType>(AllocTy)) {
if (VecTy->isScalable()) {
Constant *NullPtr = Constant::getNullValue(AllocTy->getPointerTo());
Constant *One = ConstantInt::get(IntTy, 1);
Constant *GEP = ConstantExpr::getGetElementPtr(AllocTy, NullPtr, One);
return getSCEV(ConstantExpr::getPtrToInt(GEP, IntTy));
}
if (isa<ScalableVectorType>(AllocTy)) {
Constant *NullPtr = Constant::getNullValue(AllocTy->getPointerTo());
Constant *One = ConstantInt::get(IntTy, 1);
Constant *GEP = ConstantExpr::getGetElementPtr(AllocTy, NullPtr, One);
return getSCEV(ConstantExpr::getPtrToInt(GEP, IntTy));
}
return getConstant(IntTy, getDataLayout().getTypeAllocSize(AllocTy));
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Analysis/ValueTracking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ static bool getShuffleDemandedElts(const ShuffleVectorInst *Shuf,
APInt &DemandedLHS, APInt &DemandedRHS) {
// The length of scalable vectors is unknown at compile time, thus we
// cannot check their values
if (Shuf->getType()->isScalable())
if (isa<ScalableVectorType>(Shuf->getType()))
return false;

int NumElts =
Expand Down
6 changes: 3 additions & 3 deletions llvm/lib/Analysis/VectorUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,10 @@ Value *llvm::findScalarElement(Value *V, unsigned EltNo) {
assert(V->getType()->isVectorTy() && "Not looking at a vector?");
VectorType *VTy = cast<VectorType>(V->getType());
// For fixed-length vector, return undef for out of range access.
if (!VTy->isScalable()) {
unsigned Width = VTy->getNumElements();
if (auto *FVTy = dyn_cast<FixedVectorType>(VTy)) {
unsigned Width = FVTy->getNumElements();
if (EltNo >= Width)
return UndefValue::get(VTy->getElementType());
return UndefValue::get(FVTy->getElementType());
}

if (Constant *C = dyn_cast<Constant>(V))
Expand Down

0 comments on commit 9174e02

Please sign in to comment.