[llvm] [LoopVectorizer][AArch64] Add support for partial reduce subtraction (PR #123636)
Sam Tebbs via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 7 06:23:11 PST 2025
================
@@ -8898,8 +8898,24 @@ VPRecipeBuilder::tryToCreatePartialReduction(Instruction *Reduction,
isa<VPPartialReductionRecipe>(BinOpRecipe))
std::swap(BinOp, Accumulator);
- return new VPPartialReductionRecipe(Reduction->getOpcode(), BinOp,
- Accumulator, Reduction);
+ unsigned Opcode = Reduction->getOpcode();
+ if (Opcode == Instruction::Sub) {
+ VPBasicBlock *ParentBlock = Builder.getInsertBlock();
+ // TODO Is this ever possible in normal operation, would this check be
+ // better off as an assert (if checked at all)?
+ if (!ParentBlock)
+ return nullptr;
+
+ auto *const Zero = ConstantInt::get(Reduction->getType(), 0);
+ SmallVector<VPValue *, 2> Ops;
+ Ops.push_back(Plan.getOrAddLiveIn(Zero));
+ Ops.push_back(cast<VPWidenRecipe>(BinOp->getDefiningRecipe()));
----------------
SamTebbs33 wrote:
Why does this need to cast? Can it just add `BinOp` to the list?
https://github.com/llvm/llvm-project/pull/123636
More information about the llvm-commits
mailing list