@@ -1718,15 +1718,18 @@ bool VectorCombine::scalarizeExtExtract(Instruction &I) {
1718
1718
// Try to convert a vector zext feeding only extracts to a set of scalar (Src
1719
1719
// << ExtIdx *Size) & (Size -1), if profitable.
1720
1720
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 ;
1722
1724
auto *DstTy = cast<FixedVectorType>(Ext->getType ());
1723
1725
1724
- if (DL-> getTypeSizeInBits (SrcTy) !=
1725
- DL->getTypeSizeInBits (DstTy-> getElementType () ))
1726
+ Type *ScalarDstTy = DstTy-> getElementType ();
1727
+ if ( DL->getTypeSizeInBits (SrcTy) != DL-> getTypeSizeInBits (ScalarDstTy ))
1726
1728
return false ;
1727
1729
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);
1730
1733
unsigned ExtCnt = 0 ;
1731
1734
bool ExtLane0 = false ;
1732
1735
for (User *U : Ext->users ()) {
@@ -1741,15 +1744,13 @@ bool VectorCombine::scalarizeExtExtract(Instruction &I) {
1741
1744
CostKind, Idx->getZExtValue (), U);
1742
1745
}
1743
1746
1744
- Type *ScalarDstTy = DstTy->getElementType ();
1745
1747
InstructionCost ScalarCost =
1746
1748
ExtCnt * TTI.getArithmeticInstrCost (
1747
1749
Instruction::And, ScalarDstTy, CostKind,
1748
1750
{TTI::OK_AnyValue, TTI::OP_None},
1749
1751
{TTI::OK_NonUniformConstantValue, TTI::OP_None}) +
1750
1752
(ExtCnt - ExtLane0) *
1751
1753
TTI.getArithmeticInstrCost (
1752
-
1753
1754
Instruction::LShr, ScalarDstTy, CostKind,
1754
1755
{TTI::OK_AnyValue, TTI::OP_None},
1755
1756
{TTI::OK_NonUniformConstantValue, TTI::OP_None});
0 commit comments