diff --git a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp --- a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp @@ -591,8 +591,7 @@ // Do not perform canonicalization if minmax pattern is found (to avoid // infinite loop). Type *Dummy; - if (!Ty->isIntegerTy() && Ty->isSized() && - !(Ty->isVectorTy() && cast(Ty)->isScalable()) && + if (!Ty->isIntegerTy() && Ty->isSized() && !isa(Ty) && DL.isLegalInteger(DL.getTypeStoreSizeInBits(Ty)) && DL.typeSizeEqualsStoreSize(Ty) && !DL.isNonIntegralPointerType(Ty) && !isMinMaxWithLoads( diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp --- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp +++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp @@ -1740,16 +1740,15 @@ SmallVector Ops(GEP.op_begin(), GEP.op_end()); Type *GEPType = GEP.getType(); Type *GEPEltType = GEP.getSourceElementType(); - bool IsGEPSrcEleScalable = - GEPEltType->isVectorTy() && cast(GEPEltType)->isScalable(); + bool IsGEPSrcEleScalable = isa(GEPEltType); if (Value *V = SimplifyGEPInst(GEPEltType, Ops, SQ.getWithInstruction(&GEP))) return replaceInstUsesWith(GEP, V); // For vector geps, use the generic demanded vector support. // Skip if GEP return type is scalable. The number of elements is unknown at // compile-time. - if (GEPType->isVectorTy() && !cast(GEPType)->isScalable()) { - auto VWidth = cast(GEPType)->getNumElements(); + if (auto *GEPFVTy = dyn_cast(GEPType)) { + auto VWidth = GEPFVTy->getNumElements(); APInt UndefElts(VWidth, 0); APInt AllOnesEltMask(APInt::getAllOnesValue(VWidth)); if (Value *V = SimplifyDemandedVectorElts(&GEP, AllOnesEltMask, diff --git a/llvm/lib/Transforms/Instrumentation/PoisonChecking.cpp b/llvm/lib/Transforms/Instrumentation/PoisonChecking.cpp --- a/llvm/lib/Transforms/Instrumentation/PoisonChecking.cpp +++ b/llvm/lib/Transforms/Instrumentation/PoisonChecking.cpp @@ -198,8 +198,8 @@ break; case Instruction::ExtractElement: { Value *Vec = I.getOperand(0); - auto *VecVTy = cast(Vec->getType()); - if (VecVTy->isScalable()) + auto *VecVTy = dyn_cast(Vec->getType()); + if (!VecVTy) break; Value *Idx = I.getOperand(1); unsigned NumElts = VecVTy->getNumElements(); @@ -211,8 +211,8 @@ } case Instruction::InsertElement: { Value *Vec = I.getOperand(0); - auto *VecVTy = cast(Vec->getType()); - if (VecVTy->isScalable()) + auto *VecVTy = dyn_cast(Vec->getType()); + if (!VecVTy) break; Value *Idx = I.getOperand(2); unsigned NumElts = VecVTy->getNumElements(); diff --git a/llvm/lib/Transforms/Scalar/SROA.cpp b/llvm/lib/Transforms/Scalar/SROA.cpp --- a/llvm/lib/Transforms/Scalar/SROA.cpp +++ b/llvm/lib/Transforms/Scalar/SROA.cpp @@ -4482,8 +4482,7 @@ // Skip alloca forms that this analysis can't handle. auto *AT = AI.getAllocatedType(); - if (AI.isArrayAllocation() || !AT->isSized() || - (isa(AT) && cast(AT)->isScalable()) || + if (AI.isArrayAllocation() || !AT->isSized() || isa(AT) || DL.getTypeAllocSize(AT).getFixedSize() == 0) return false; @@ -4605,8 +4604,7 @@ for (BasicBlock::iterator I = EntryBB.begin(), E = std::prev(EntryBB.end()); I != E; ++I) { if (AllocaInst *AI = dyn_cast(I)) { - if (isa(AI->getAllocatedType()) && - cast(AI->getAllocatedType())->isScalable()) { + if (isa(AI->getAllocatedType())) { if (isAllocaPromotable(AI)) PromotableAllocas.push_back(AI); } else { diff --git a/llvm/lib/Transforms/Utils/VNCoercion.cpp b/llvm/lib/Transforms/Utils/VNCoercion.cpp --- a/llvm/lib/Transforms/Utils/VNCoercion.cpp +++ b/llvm/lib/Transforms/Utils/VNCoercion.cpp @@ -11,8 +11,7 @@ namespace VNCoercion { static bool isFirstClassAggregateOrScalableType(Type *Ty) { - return Ty->isStructTy() || Ty->isArrayTy() || - (Ty->isVectorTy() && cast(Ty)->isScalable()); + return Ty->isStructTy() || Ty->isArrayTy() || isa(Ty); } /// Return true if coerceAvailableValueToLoadType will succeed.