@@ -451,7 +451,6 @@ bool VectorCombine::isExtractExtractCheap(ExtractElementInst *Ext0,
451451 // operands to element 0.
452452 unsigned BestExtIndex = Extract0Cost > Extract1Cost ? Ext0Index : Ext1Index;
453453 unsigned BestInsIndex = Extract0Cost > Extract1Cost ? Ext1Index : Ext0Index;
454- Value *BestVec = (Extract0Cost > Extract1Cost ? Ext1 : Ext0)->getOperand (0 );
455454 InstructionCost CheapExtractCost = std::min (Extract0Cost, Extract1Cost);
456455
457456 // Extra uses of the extracts mean that we include those costs in the
@@ -491,12 +490,13 @@ bool VectorCombine::isExtractExtractCheap(ExtractElementInst *Ext0,
491490 SmallVector<int > ShuffleMask (FixedVecTy->getNumElements (),
492491 PoisonMaskElem);
493492 ShuffleMask[BestInsIndex] = BestExtIndex;
493+ NewCost += TTI.getShuffleCost (TargetTransformInfo::SK_PermuteSingleSrc,
494+ VecTy, ShuffleMask, CostKind, 0 , nullptr ,
495+ {ConvertToShuffle});
496+ } else {
494497 NewCost +=
495498 TTI.getShuffleCost (TargetTransformInfo::SK_PermuteSingleSrc, VecTy,
496- ShuffleMask, CostKind, 0 , nullptr , {BestVec});
497- } else {
498- NewCost += TTI.getShuffleCost (TargetTransformInfo::SK_PermuteSingleSrc,
499- VecTy, {}, CostKind, 0 , nullptr , {BestVec});
499+ {}, CostKind, 0 , nullptr , {ConvertToShuffle});
500500 }
501501 }
502502
0 commit comments