[llvm] [LoopVectorizer][AArch64] Add support for partial reduce subtraction (PR #123636)
Sam Tebbs via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 30 03:01:29 PST 2025
================
@@ -282,7 +283,20 @@ InstructionCost
VPPartialReductionRecipe::computeCost(ElementCount VF,
VPCostContext &Ctx) const {
std::optional<unsigned> Opcode = std::nullopt;
- VPRecipeBase *BinOpR = getOperand(0)->getDefiningRecipe();
+ VPValue *BinOp = getOperand(0);
+ VPRecipeBase *BinOpR = BinOp->getDefiningRecipe();
+
+ using namespace llvm::PatternMatch;
+ if (auto *UnderInst =
+ dyn_cast_if_present<Instruction>(BinOp->getUnderlyingValue())) {
+ if (match(UnderInst, m_Neg(m_BinOp()))) {
+ BinOpR = BinOpR->getOperand(1)->getDefiningRecipe();
+ }
+ }
+ // BinOp is never used again, any further interaction should be via the
+ // defining recipe `BinOpR`
+ BinOp = nullptr;
+
----------------
SamTebbs33 wrote:
It feels a bit strange to set something to null like this, perhaps it should just be left alone. Or we could just not declare the variable in the first place and use `getOperand(0)` instead.
https://github.com/llvm/llvm-project/pull/123636
More information about the llvm-commits
mailing list