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

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 16 00:06:26 PDT 2025


================
@@ -8141,8 +8141,11 @@ VPRecipeBase *VPRecipeBuilder::tryToCreateWidenRecipe(VPSingleDefRecipe *R,
   if (isa<LoadInst>(Instr) || isa<StoreInst>(Instr))
     return tryToWidenMemory(Instr, Operands, Range);
 
-  if (std::optional<unsigned> ScaleFactor = getScalingForReduction(Instr))
-    return tryToCreatePartialReduction(Instr, Operands, ScaleFactor.value());
+  if (std::optional<unsigned> ScaleFactor = getScalingForReduction(Instr)) {
+    if (auto PartialRed =
+            tryToCreatePartialReduction(Instr, Operands, ScaleFactor.value()))
+      return PartialRed;
+  }
----------------
lukel97 wrote:

I think this is intentional? tryToCreatePartialReduction can now return nullptr on line 8185 so I presume we need to check it here. 

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


More information about the llvm-commits mailing list