[llvm] [LV] NFCI: Add RecurKind to VPPartialReductionChain (PR #181705)

Benjamin Maxwell via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 17 02:35:37 PST 2026


================
@@ -5964,14 +5968,11 @@ getScaledReductions(VPSingleDefRecipe *RedPhiR, VPValue *PrevValue,
   // If one is found, we use the discovered reduction instruction in
   // place of the accumulator for costing.
   if (getScaledReductions(RedPhiR, Op, Chains, CostCtx, Range)) {
-    RedPhiR = Chains.rbegin()->ReductionBinOp;
     Op = UpdateR->getOperand(0);
     PhiOp = UpdateR->getOperand(1);
-    if (Op == RedPhiR)
+    if (Op == Chains.rbegin()->ReductionBinOp)
       std::swap(Op, PhiOp);
   }
-  if (RedPhiR != PhiOp)
----------------
MacDue wrote:

An example is:
```
    EMIT vp<%6> = CANONICAL-INDUCTION ir<0>, vp<%index.next>
    ir<%tmp> = WIDEN-INDUCTION nsw ir<%count>, ir<%count>, vp<%0>
    WIDEN-REDUCTION-PHI ir<%result.1> = phi vp<%5>, ir<%add>
    WIDEN ir<%shr> = ashr ir<%val>, ir<%tmp>
    WIDEN ir<%add> = add ir<%shr>, ir<%result.1>
```
Starting from `%add`, if you get to `%shr` neither operand is the reduction phi. 

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


More information about the llvm-commits mailing list