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

Benjamin Maxwell via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 17 10:08:48 PDT 2025


================
@@ -9144,6 +9144,15 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
             CurrentLinkI->getFastMathFlags());
         LinkVPBB->insert(FMulRecipe, CurrentLink->getIterator());
         VecOp = FMulRecipe;
+      } else if (PhiR->isInLoop() && Kind == RecurKind::Sub &&
+                 CurrentLinkI->getOpcode() == Instruction::Sub) {
----------------
MacDue wrote:

This case is no-longer tested, and at does somewhat confuse me (maybe just needs a comment). I'd think you'd negate the input for a `sub` in an `add` reduction, not a `sub` in a `sub` reduction? 

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


More information about the llvm-commits mailing list