@@ -1778,15 +1778,18 @@ bool VectorCombine::scalarizeExtExtract(Instruction &I) {
1778
1778
// Try to convert a vector zext feeding only extracts to a set of scalar (Src
1779
1779
// << ExtIdx *Size) & (Size -1), if profitable.
1780
1780
auto *Ext = cast<ZExtInst>(&I);
1781
- auto *SrcTy = cast<FixedVectorType>(Ext->getOperand (0 )->getType ());
1781
+ auto *SrcTy = dyn_cast<FixedVectorType>(Ext->getOperand (0 )->getType ());
1782
+ if (!SrcTy)
1783
+ return false ;
1782
1784
auto *DstTy = cast<FixedVectorType>(Ext->getType ());
1783
1785
1784
- if (DL-> getTypeSizeInBits (SrcTy) !=
1785
- DL->getTypeSizeInBits (DstTy-> getElementType () ))
1786
+ Type *ScalarDstTy = DstTy-> getElementType ();
1787
+ if ( DL->getTypeSizeInBits (SrcTy) != DL-> getTypeSizeInBits (ScalarDstTy ))
1786
1788
return false ;
1787
1789
1788
- InstructionCost VectorCost = TTI.getCastInstrCost (
1789
- Instruction::ZExt, DstTy, SrcTy, TTI::CastContextHint::None, CostKind);
1790
+ InstructionCost VectorCost =
1791
+ TTI.getCastInstrCost (Instruction::ZExt, DstTy, SrcTy,
1792
+ TTI::CastContextHint::None, CostKind, Ext);
1790
1793
unsigned ExtCnt = 0 ;
1791
1794
bool ExtLane0 = false ;
1792
1795
for (User *U : Ext->users ()) {
@@ -1801,15 +1804,13 @@ bool VectorCombine::scalarizeExtExtract(Instruction &I) {
1801
1804
CostKind, Idx->getZExtValue (), U);
1802
1805
}
1803
1806
1804
- Type *ScalarDstTy = DstTy->getElementType ();
1805
1807
InstructionCost ScalarCost =
1806
1808
ExtCnt * TTI.getArithmeticInstrCost (
1807
1809
Instruction::And, ScalarDstTy, CostKind,
1808
1810
{TTI::OK_AnyValue, TTI::OP_None},
1809
1811
{TTI::OK_NonUniformConstantValue, TTI::OP_None}) +
1810
1812
(ExtCnt - ExtLane0) *
1811
1813
TTI.getArithmeticInstrCost (
1812
-
1813
1814
Instruction::LShr, ScalarDstTy, CostKind,
1814
1815
{TTI::OK_AnyValue, TTI::OP_None},
1815
1816
{TTI::OK_NonUniformConstantValue, TTI::OP_None});
0 commit comments