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

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 1 03:01:15 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());
----------------
fhahn wrote:

So this is to support chains of instructions ,where the first one is an add, but the backedge value is a sub, right?

Do we have a test with in-loop reductions for that to make sure we handle this correctly?

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


More information about the llvm-commits mailing list