[llvm] [LV] Create in-loop sub reductions (PR #147026)

Sam Tebbs via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 4 04:01:45 PDT 2025


================
@@ -897,8 +898,19 @@ RecurrenceDescriptor::InstDesc RecurrenceDescriptor::isRecurrenceInstr(
   case Instruction::PHI:
     return InstDesc(I, Prev.getRecKind(), Prev.getExactFPMathInst());
   case Instruction::Sub:
+    if (Prev.getRecKind() == RecurKind::Add && Kind == RecurKind::Add)
+      return InstDesc(I, Prev.getRecKind());
----------------
SamTebbs33 wrote:

Yep, that's correct. We have partial-reduce-chained.ll which tests for the first one being an add and the backedge value being a sub, but those weren't creating inloop reductions so I have added a more explicit test to reduction-inloop.ll and re-added some checks that are necessary for mixed in-loop reductions. Thank you.

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


More information about the llvm-commits mailing list