[llvm] 9174e02 - [SVE] Remove calls to VectorType::isScalable from analysis

Christopher Tetreault via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 23 12:44:36 PDT 2020


Author: Christopher Tetreault
Date: 2020-04-23T12:44:22-07:00
New Revision: 9174e0229fcbe32967addda74a7beb7bb43cf17c

URL: https://github.com/llvm/llvm-project/commit/9174e0229fcbe32967addda74a7beb7bb43cf17c
DIFF: https://github.com/llvm/llvm-project/commit/9174e0229fcbe32967addda74a7beb7bb43cf17c.diff

LOG: [SVE] Remove calls to VectorType::isScalable from analysis

Reviewers: efriedma, sdesmalen, chandlerc, sunfish

Reviewed By: efriedma

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

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D77692

Added: 
    

Modified: 
    llvm/lib/Analysis/BasicAliasAnalysis.cpp
    llvm/lib/Analysis/ConstantFolding.cpp
    llvm/lib/Analysis/InstructionSimplify.cpp
    llvm/lib/Analysis/Loads.cpp
    llvm/lib/Analysis/MemoryBuiltins.cpp
    llvm/lib/Analysis/ScalarEvolution.cpp
    llvm/lib/Analysis/ValueTracking.cpp
    llvm/lib/Analysis/VectorUtils.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
index 04a3a5487d39..5fdfb7d49073 100644
--- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
@@ -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;

diff  --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp
index 351e36f06fda..b2bde95355e7 100644
--- a/llvm/lib/Analysis/ConstantFolding.cpp
+++ b/llvm/lib/Analysis/ConstantFolding.cpp
@@ -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());
@@ -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,
@@ -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) {

diff  --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index 4bcdd4849bc7..f023899484fb 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -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.
@@ -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());
   }
 
@@ -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;

diff  --git a/llvm/lib/Analysis/Loads.cpp b/llvm/lib/Analysis/Loads.cpp
index 9919440ce109..02be3693c35b 100644
--- a/llvm/lib/Analysis/Loads.cpp
+++ b/llvm/lib/Analysis/Loads.cpp
@@ -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

diff  --git a/llvm/lib/Analysis/MemoryBuiltins.cpp b/llvm/lib/Analysis/MemoryBuiltins.cpp
index ce5a56f8d062..fc504b7f9c63 100644
--- a/llvm/lib/Analysis/MemoryBuiltins.cpp
+++ b/llvm/lib/Analysis/MemoryBuiltins.cpp
@@ -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()));

diff  --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 75891aebf4a8..330674fedd8e 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -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));
 }

diff  --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 5ef5abc782d3..0e9564137170 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -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 =

diff  --git a/llvm/lib/Analysis/VectorUtils.cpp b/llvm/lib/Analysis/VectorUtils.cpp
index 59bff32ff885..a96686aaf1c5 100644
--- a/llvm/lib/Analysis/VectorUtils.cpp
+++ b/llvm/lib/Analysis/VectorUtils.cpp
@@ -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))


        


More information about the llvm-commits mailing list