[llvm] [VectorCombine] foldShuffleChainsToReduce - add support for partial vector reductions (PR #195119)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Sun May 3 08:16:09 PDT 2026
================
@@ -4147,14 +4156,32 @@ bool VectorCombine::foldShuffleChainsToReduce(Instruction &I) {
if (!ReducedOp)
return false;
- IntrinsicCostAttributes ICA(ReducedOp, FinalVecVTy, {FinalVecV});
- InstructionCost NewCost = TTI.getIntrinsicInstrCost(ICA, CostKind);
+ InstructionCost NewCost = 0;
+ FixedVectorType *ReduceVecTy = FinalVecVTy;
+
+ if (IsPartialReduction) {
+ unsigned SubVecSize = ShuffleMaskHalf;
+ ReduceVecTy = FixedVectorType::get(FVT->getElementType(), SubVecSize);
+ NewCost += TTI.getShuffleCost(TargetTransformInfo::SK_ExtractSubvector,
----------------
RKSimon wrote:
Create the ExtractMask earlier and add the mask to getShuffleCost - its always better to provide an explicit mask to getShuffleCost if you can, even for something as mundane as SK_ExtractSubvector
https://github.com/llvm/llvm-project/pull/195119
More information about the llvm-commits
mailing list