Skip to content

Commit 78fd2c4

Browse files
committed
more accurate shufflecost with PermuteSingleSrc
1 parent 5c694ff commit 78fd2c4

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

llvm/lib/Transforms/Vectorize/VectorCombine.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -699,9 +699,12 @@ bool VectorCombine::foldInsExtFNeg(Instruction &I) {
699699
bool NeedLenChg = SrcVecTy->getNumElements() != NumElts;
700700
// If the lengths of the two vectors are not equal,
701701
// we need to add a length-change vector. Add this cost.
702-
if (NeedLenChg)
703-
NewCost +=
704-
TTI.getShuffleCost(TargetTransformInfo::SK_Select, SrcVecTy, Mask);
702+
SmallVector<int> SrcMask;
703+
if (NeedLenChg) {
704+
SrcMask.assign(NumElts, PoisonMaskElem);
705+
NewCost += TTI.getShuffleCost(TargetTransformInfo::SK_PermuteSingleSrc,
706+
SrcVecTy, SrcMask, CostKind);
707+
}
705708

706709
if (NewCost > OldCost)
707710
return false;
@@ -711,7 +714,6 @@ bool VectorCombine::foldInsExtFNeg(Instruction &I) {
711714
Value *VecFNeg = Builder.CreateFNegFMF(SrcVec, FNeg);
712715
if (NeedLenChg) {
713716
// shuffle DestVec, (shuffle (fneg SrcVec), poison, SrcMask), Mask
714-
SmallVector<int> SrcMask(NumElts, PoisonMaskElem);
715717
SrcMask[Index] = Index;
716718
Value *LenChgShuf = Builder.CreateShuffleVector(
717719
SrcVec, PoisonValue::get(SrcVecTy), SrcMask);

0 commit comments

Comments
 (0)