[llvm] [VPlan] Add VPBundleRecipe, replacing extended reduction recipes. (PR #144281)

Elvis Wang via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 15 18:08:29 PDT 2025


================
@@ -267,6 +267,9 @@ Type *VPTypeAnalysis::inferScalarType(const VPValue *V) {
 
   Type *ResultTy =
       TypeSwitch<const VPRecipeBase *, Type *>(V->getDefiningRecipe())
+          .Case<VPBundleRecipe>([this](const auto *R) {
+            return inferScalarType(R->getOperand(R->getNumOperands() - 2));
----------------
ElvisWang123 wrote:

The Reduction recipe is the last recipes so the operands in it will be last two (or three if optional) ops. But the `vecOp` is already defined in the bundle (at least for mul-accumulate reduction and extended-reduction). So the `ChainOp` which contains the reduction type  will be the -1 (or -2) operand of the VPBundle recipe.

I think with this fix the cost of extended-reduction will be correct and this patch can be NFC.

https://github.com/llvm/llvm-project/pull/144281


More information about the llvm-commits mailing list