[llvm] [VectorCombine] Combine scalar fneg with insert/extract to vector fneg when length is different (PR #115209)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 9 14:31:34 PST 2024
================
@@ -697,14 +698,32 @@ bool VectorCombine::foldInsExtFNeg(Instruction &I) {
TTI.getArithmeticInstrCost(Instruction::FNeg, VecTy, CostKind) +
TTI.getShuffleCost(TargetTransformInfo::SK_Select, VecTy, Mask, CostKind);
+ bool NeedLenChg = SrcVecTy->getNumElements() != NumElts;
+ // If the lengths of the two vectors are not equal,
+ // we need to add a length-change vector. Add this cost.
+ if (NeedLenChg)
+ NewCost +=
+ TTI.getShuffleCost(TargetTransformInfo::SK_Select, SrcVecTy, Mask);
----------------
RKSimon wrote:
Shouldn't be a Select shuffle kind? Create the SrcMask below earlier and use SingleSrc SK.
https://github.com/llvm/llvm-project/pull/115209
More information about the llvm-commits
mailing list