From: Craig Topper Date: Thu, 29 Dec 2016 07:03:18 +0000 (+0000) Subject: [InstCombine] Use getVectorNumElements instead of explicitly casting to VectorType... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f05137f8f8fb80f74364731efc9c98315c39dcf6;p=llvm [InstCombine] Use getVectorNumElements instead of explicitly casting to VectorType and calling getNumElements. NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@290707 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/InstCombine/InstCombineVectorOps.cpp b/lib/Transforms/InstCombine/InstCombineVectorOps.cpp index ada5bc9627d..b2477f6c863 100644 --- a/lib/Transforms/InstCombine/InstCombineVectorOps.cpp +++ b/lib/Transforms/InstCombine/InstCombineVectorOps.cpp @@ -460,7 +460,7 @@ static ShuffleOps collectShuffleElements(Value *V, Value *PermittedRHS, InstCombiner &IC) { assert(V->getType()->isVectorTy() && "Invalid shuffle!"); - unsigned NumElts = cast(V->getType())->getNumElements(); + unsigned NumElts = V->getType()->getVectorNumElements(); if (isa(V)) { Mask.assign(NumElts, UndefValue::get(Type::getInt32Ty(V->getContext()))); @@ -794,7 +794,7 @@ Instruction *InstCombiner::visitInsertElementInst(InsertElementInst &IE) { } } - unsigned VWidth = cast(VecOp->getType())->getNumElements(); + unsigned VWidth = VecOp->getType()->getVectorNumElements(); APInt UndefElts(VWidth, 0); APInt AllOnesEltMask(APInt::getAllOnesValue(VWidth)); if (Value *V = SimplifyDemandedVectorElts(&IE, AllOnesEltMask, UndefElts)) { @@ -1089,8 +1089,7 @@ static void recognizeIdentityMask(const SmallVectorImpl &Mask, // +--+--+--+--+ static bool isShuffleExtractingFromLHS(ShuffleVectorInst &SVI, SmallVector &Mask) { - unsigned LHSElems = - cast(SVI.getOperand(0)->getType())->getNumElements(); + unsigned LHSElems = SVI.getOperand(0)->getType()->getVectorNumElements(); unsigned MaskElems = Mask.size(); unsigned BegIdx = Mask.front(); unsigned EndIdx = Mask.back(); @@ -1114,7 +1113,7 @@ Instruction *InstCombiner::visitShuffleVectorInst(ShuffleVectorInst &SVI) { if (isa(SVI.getOperand(2))) return replaceInstUsesWith(SVI, UndefValue::get(SVI.getType())); - unsigned VWidth = cast(SVI.getType())->getNumElements(); + unsigned VWidth = SVI.getType()->getVectorNumElements(); APInt UndefElts(VWidth, 0); APInt AllOnesEltMask(APInt::getAllOnesValue(VWidth)); @@ -1126,7 +1125,7 @@ Instruction *InstCombiner::visitShuffleVectorInst(ShuffleVectorInst &SVI) { MadeChange = true; } - unsigned LHSWidth = cast(LHS->getType())->getNumElements(); + unsigned LHSWidth = LHS->getType()->getVectorNumElements(); // Canonicalize shuffle(x ,x,mask) -> shuffle(x, undef,mask') // Canonicalize shuffle(undef,x,mask) -> shuffle(x, undef,mask'). @@ -1329,11 +1328,11 @@ Instruction *InstCombiner::visitShuffleVectorInst(ShuffleVectorInst &SVI) { if (LHSShuffle) { LHSOp0 = LHSShuffle->getOperand(0); LHSOp1 = LHSShuffle->getOperand(1); - LHSOp0Width = cast(LHSOp0->getType())->getNumElements(); + LHSOp0Width = LHSOp0->getType()->getVectorNumElements(); } if (RHSShuffle) { RHSOp0 = RHSShuffle->getOperand(0); - RHSOp0Width = cast(RHSOp0->getType())->getNumElements(); + RHSOp0Width = RHSOp0->getType()->getVectorNumElements(); } Value* newLHS = LHS; Value* newRHS = RHS;