[llvm] [LoopVectorizer][AArch64] Add support for partial reduce subtraction (PR #123636)

Nicholas Guy via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 31 05:49:06 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();
+    }
----------------
NickGuy-Arm wrote:

We can indeed. Done.

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


More information about the llvm-commits mailing list