[llvm] [LV] Add support for absolute difference partial reductions (PR #188043)

Sander de Smalen via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 14 08:33:39 PDT 2026


================
@@ -6030,6 +6030,31 @@ optimizeExtendsForPartialReduction(VPSingleDefRecipe *BinOp,
     return BinOp;
   }
 
+  // reduce.add(abs(sub(ext(A), ext(B))))
+  // -> reduce.add(ext(absolute-difference(A, B)))
+  VPValue *X, *Y;
+  if (match(BinOp,
+            m_Intrinsic<Intrinsic::abs>(m_Sub(m_ZExtOrSExt(m_VPValue(X)),
+                                              m_ZExtOrSExt(m_VPValue(Y)))))) {
+    auto *Ext = cast<VPWidenCastRecipe>(
+        BinOp->getOperand(0)->getDefiningRecipe()->getOperand(0));
----------------
sdesmalen-arm wrote:

Can you assert that both operands have the same extend kind?

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


More information about the llvm-commits mailing list