Skip to content

Commit

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

Reviewed By: efriedma

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

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D77756
  • Loading branch information
christetreault-llvm committed Apr 23, 2020
1 parent 542668d commit 7ca56c9
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 16 deletions.
Expand Up @@ -591,8 +591,7 @@ static Instruction *combineLoadToOperationType(InstCombiner &IC, LoadInst &LI) {
// Do not perform canonicalization if minmax pattern is found (to avoid
// infinite loop).
Type *Dummy;
if (!Ty->isIntegerTy() && Ty->isSized() &&
!(Ty->isVectorTy() && cast<VectorType>(Ty)->isScalable()) &&
if (!Ty->isIntegerTy() && Ty->isSized() && !isa<ScalableVectorType>(Ty) &&
DL.isLegalInteger(DL.getTypeStoreSizeInBits(Ty)) &&
DL.typeSizeEqualsStoreSize(Ty) && !DL.isNonIntegralPointerType(Ty) &&
!isMinMaxWithLoads(
Expand Down
7 changes: 3 additions & 4 deletions llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
Expand Up @@ -1740,16 +1740,15 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) {
SmallVector<Value*, 8> Ops(GEP.op_begin(), GEP.op_end());
Type *GEPType = GEP.getType();
Type *GEPEltType = GEP.getSourceElementType();
bool IsGEPSrcEleScalable =
GEPEltType->isVectorTy() && cast<VectorType>(GEPEltType)->isScalable();
bool IsGEPSrcEleScalable = isa<ScalableVectorType>(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<VectorType>(GEPType)->isScalable()) {
auto VWidth = cast<VectorType>(GEPType)->getNumElements();
if (auto *GEPFVTy = dyn_cast<FixedVectorType>(GEPType)) {
auto VWidth = GEPFVTy->getNumElements();
APInt UndefElts(VWidth, 0);
APInt AllOnesEltMask(APInt::getAllOnesValue(VWidth));
if (Value *V = SimplifyDemandedVectorElts(&GEP, AllOnesEltMask,
Expand Down
8 changes: 4 additions & 4 deletions llvm/lib/Transforms/Instrumentation/PoisonChecking.cpp
Expand Up @@ -198,8 +198,8 @@ static void generateCreationChecks(Instruction &I,
break;
case Instruction::ExtractElement: {
Value *Vec = I.getOperand(0);
auto *VecVTy = cast<VectorType>(Vec->getType());
if (VecVTy->isScalable())
auto *VecVTy = dyn_cast<FixedVectorType>(Vec->getType());
if (!VecVTy)
break;
Value *Idx = I.getOperand(1);
unsigned NumElts = VecVTy->getNumElements();
Expand All @@ -211,8 +211,8 @@ static void generateCreationChecks(Instruction &I,
}
case Instruction::InsertElement: {
Value *Vec = I.getOperand(0);
auto *VecVTy = cast<VectorType>(Vec->getType());
if (VecVTy->isScalable())
auto *VecVTy = dyn_cast<FixedVectorType>(Vec->getType());
if (!VecVTy)
break;
Value *Idx = I.getOperand(2);
unsigned NumElts = VecVTy->getNumElements();
Expand Down
6 changes: 2 additions & 4 deletions llvm/lib/Transforms/Scalar/SROA.cpp
Expand Up @@ -4482,8 +4482,7 @@ bool SROA::runOnAlloca(AllocaInst &AI) {

// Skip alloca forms that this analysis can't handle.
auto *AT = AI.getAllocatedType();
if (AI.isArrayAllocation() || !AT->isSized() ||
(isa<VectorType>(AT) && cast<VectorType>(AT)->isScalable()) ||
if (AI.isArrayAllocation() || !AT->isSized() || isa<ScalableVectorType>(AT) ||
DL.getTypeAllocSize(AT).getFixedSize() == 0)
return false;

Expand Down Expand Up @@ -4605,8 +4604,7 @@ PreservedAnalyses SROA::runImpl(Function &F, DominatorTree &RunDT,
for (BasicBlock::iterator I = EntryBB.begin(), E = std::prev(EntryBB.end());
I != E; ++I) {
if (AllocaInst *AI = dyn_cast<AllocaInst>(I)) {
if (isa<VectorType>(AI->getAllocatedType()) &&
cast<VectorType>(AI->getAllocatedType())->isScalable()) {
if (isa<ScalableVectorType>(AI->getAllocatedType())) {
if (isAllocaPromotable(AI))
PromotableAllocas.push_back(AI);
} else {
Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/Transforms/Utils/VNCoercion.cpp
Expand Up @@ -11,8 +11,7 @@ namespace llvm {
namespace VNCoercion {

static bool isFirstClassAggregateOrScalableType(Type *Ty) {
return Ty->isStructTy() || Ty->isArrayTy() ||
(Ty->isVectorTy() && cast<VectorType>(Ty)->isScalable());
return Ty->isStructTy() || Ty->isArrayTy() || isa<ScalableVectorType>(Ty);
}

/// Return true if coerceAvailableValueToLoadType will succeed.
Expand Down

0 comments on commit 7ca56c9

Please sign in to comment.