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

Sander de Smalen via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 31 05:20:31 PDT 2025


================
@@ -1288,6 +1308,10 @@ RecurrenceDescriptor::getReductionOpChain(PHINode *Phi, Loop *L) const {
     if (isFMulAddIntrinsic(Cur))
       return true;
 
+    // Recognize a sub reduction. It gets canonicalized to add(sub (0, ...)).
+    if (Cur->getOpcode() == Instruction::Sub && getOpcode() == Instruction::Add)
+      return true;
+
----------------
sdesmalen-arm wrote:

When I now remove this code, all tests still pass. Is this code still needed?

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


More information about the llvm-commits mailing list