[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:22 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();
+    }
+  }
----------------
SamTebbs33 wrote:

A comment explaining why this has to get the 2nd operand of the BinOp would be good.

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


More information about the llvm-commits mailing list