@@ -1782,15 +1782,18 @@ bool VectorCombine::scalarizeExtExtract(Instruction &I) {
17821782 // Try to convert a vector zext feeding only extracts to a set of scalar (Src
17831783 // << ExtIdx *Size) & (Size -1), if profitable.
17841784 auto *Ext = cast<ZExtInst>(&I);
1785- auto *SrcTy = cast<FixedVectorType>(Ext->getOperand (0 )->getType ());
1785+ auto *SrcTy = dyn_cast<FixedVectorType>(Ext->getOperand (0 )->getType ());
1786+ if (!SrcTy)
1787+ return false ;
17861788 auto *DstTy = cast<FixedVectorType>(Ext->getType ());
17871789
1788- if (DL-> getTypeSizeInBits (SrcTy) !=
1789- DL->getTypeSizeInBits (DstTy-> getElementType () ))
1790+ Type *ScalarDstTy = DstTy-> getElementType ();
1791+ if ( DL->getTypeSizeInBits (SrcTy) != DL-> getTypeSizeInBits (ScalarDstTy ))
17901792 return false ;
17911793
1792- InstructionCost VectorCost = TTI.getCastInstrCost (
1793- Instruction::ZExt, DstTy, SrcTy, TTI::CastContextHint::None, CostKind);
1794+ InstructionCost VectorCost =
1795+ TTI.getCastInstrCost (Instruction::ZExt, DstTy, SrcTy,
1796+ TTI::CastContextHint::None, CostKind, Ext);
17941797 unsigned ExtCnt = 0 ;
17951798 bool ExtLane0 = false ;
17961799 for (User *U : Ext->users ()) {
@@ -1805,15 +1808,13 @@ bool VectorCombine::scalarizeExtExtract(Instruction &I) {
18051808 CostKind, Idx->getZExtValue (), U);
18061809 }
18071810
1808- Type *ScalarDstTy = DstTy->getElementType ();
18091811 InstructionCost ScalarCost =
18101812 ExtCnt * TTI.getArithmeticInstrCost (
18111813 Instruction::And, ScalarDstTy, CostKind,
18121814 {TTI::OK_AnyValue, TTI::OP_None},
18131815 {TTI::OK_NonUniformConstantValue, TTI::OP_None}) +
18141816 (ExtCnt - ExtLane0) *
18151817 TTI.getArithmeticInstrCost (
1816-
18171818 Instruction::LShr, ScalarDstTy, CostKind,
18181819 {TTI::OK_AnyValue, TTI::OP_None},
18191820 {TTI::OK_NonUniformConstantValue, TTI::OP_None});
0 commit comments