@@ -1718,15 +1718,18 @@ bool VectorCombine::scalarizeExtExtract(Instruction &I) {
17181718 // Try to convert a vector zext feeding only extracts to a set of scalar (Src
17191719 // << ExtIdx *Size) & (Size -1), if profitable.
17201720 auto *Ext = cast<ZExtInst>(&I);
1721- auto *SrcTy = cast<FixedVectorType>(Ext->getOperand (0 )->getType ());
1721+ auto *SrcTy = dyn_cast<FixedVectorType>(Ext->getOperand (0 )->getType ());
1722+ if (!SrcTy)
1723+ return false ;
17221724 auto *DstTy = cast<FixedVectorType>(Ext->getType ());
17231725
1724- if (DL-> getTypeSizeInBits (SrcTy) !=
1725- DL->getTypeSizeInBits (DstTy-> getElementType () ))
1726+ Type *ScalarDstTy = DstTy-> getElementType ();
1727+ if ( DL->getTypeSizeInBits (SrcTy) != DL-> getTypeSizeInBits (ScalarDstTy ))
17261728 return false ;
17271729
1728- InstructionCost VectorCost = TTI.getCastInstrCost (
1729- Instruction::ZExt, DstTy, SrcTy, TTI::CastContextHint::None, CostKind);
1730+ InstructionCost VectorCost =
1731+ TTI.getCastInstrCost (Instruction::ZExt, DstTy, SrcTy,
1732+ TTI::CastContextHint::None, CostKind, Ext);
17301733 unsigned ExtCnt = 0 ;
17311734 bool ExtLane0 = false ;
17321735 for (User *U : Ext->users ()) {
@@ -1741,15 +1744,13 @@ bool VectorCombine::scalarizeExtExtract(Instruction &I) {
17411744 CostKind, Idx->getZExtValue (), U);
17421745 }
17431746
1744- Type *ScalarDstTy = DstTy->getElementType ();
17451747 InstructionCost ScalarCost =
17461748 ExtCnt * TTI.getArithmeticInstrCost (
17471749 Instruction::And, ScalarDstTy, CostKind,
17481750 {TTI::OK_AnyValue, TTI::OP_None},
17491751 {TTI::OK_NonUniformConstantValue, TTI::OP_None}) +
17501752 (ExtCnt - ExtLane0) *
17511753 TTI.getArithmeticInstrCost (
1752-
17531754 Instruction::LShr, ScalarDstTy, CostKind,
17541755 {TTI::OK_AnyValue, TTI::OP_None},
17551756 {TTI::OK_NonUniformConstantValue, TTI::OP_None});
0 commit comments