[llvm] [LV] Create in-loop sub reductions (PR #147026)
Sam Tebbs via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 17 01:58:50 PDT 2025
================
@@ -9144,6 +9144,14 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
CurrentLinkI->getFastMathFlags());
LinkVPBB->insert(FMulRecipe, CurrentLink->getIterator());
VecOp = FMulRecipe;
+ } else if (PhiR->isInLoop() && Kind == RecurKind::Add &&
+ CurrentLinkI->getOpcode() == Instruction::Sub) {
+ Type *PhiTy = PhiR->getUnderlyingValue()->getType();
+ auto *Zero = Plan->getOrAddLiveIn(ConstantInt::get(PhiTy, 0));
+ VPWidenRecipe *Sub = new VPWidenRecipe(
+ *CurrentLinkI, {Zero, CurrentLink->getOperand(1)});
----------------
SamTebbs33 wrote:
Done.
https://github.com/llvm/llvm-project/pull/147026
More information about the llvm-commits
mailing list