[llvm] [LV] Don't create partial reductions if factor doesn't match accumulator (PR #158603)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 16 07:36:29 PDT 2025


================
@@ -141,3 +141,17 @@ VPBasicBlock *vputils::getFirstLoopHeader(VPlan &Plan, VPDominatorTree &VPDT) {
   });
   return I == DepthFirst.end() ? nullptr : cast<VPBasicBlock>(*I);
 }
+
+unsigned vputils::getVFScaleFactor(VPRecipeBase *R) {
+  if (!R)
+    return 1;
+  if (auto *RR = dyn_cast<VPReductionPHIRecipe>(R))
+    return RR->getVFScaleFactor();
+  if (auto *RR = dyn_cast<VPPartialReductionRecipe>(R))
+    return RR->getVFScaleFactor();
+  assert(
+      (!isa<VPInstruction>(R) || cast<VPInstruction>(R)->getOpcode() !=
+                                     VPInstruction::ReductionStartVector) &&
+      "getting scaling factor of reduction-start-vector not implemented yet");
----------------
fhahn wrote:

This just moves the existing code and allows `R` to be a `nullptr`, so I don't think this should introduce a new assertion failure.

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


More information about the llvm-commits mailing list