[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


================
@@ -8176,6 +8179,10 @@ VPRecipeBuilder::tryToCreatePartialReduction(Instruction *Reduction,
       isa<VPPartialReductionRecipe>(BinOpRecipe))
     std::swap(BinOp, Accumulator);
 
+  if (ScaleFactor !=
----------------
fhahn wrote:

> Why does the scale-factor of the accumulator (PHI) not match that of the reduction? Is there something missing elsewhere that causes this to not match?

Ths can happen when there's a chain and the first entry can use a partial reduction but the second entry in the chain cannot. 

> Possibly unrelated, but when I print the values of BinOp/Accumulator, I see that BinOp = WIDEN_REDUCTION-PHI and Accumulator = WIDEN-CAST, which is then swapped above to result in BinOp = WIDEN-CAST. That does not look like a binary-op to me, so. Is this poorly named or does the code actually assume a 'dot-product'-like operation which is not what it gets?


I think it is poorly named, as this also supports using dot product instructions  for widening adds, by multiplying with 1

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


More information about the llvm-commits mailing list