[Mlir-commits] [mlir] [mlir][linalg] Support subtracting accumulation in partial reduction … (PR #214033)

Federico Bruzzone llvmlistbot at llvm.org
Fri Aug 7 03:23:38 PDT 2026


================
@@ -534,6 +534,28 @@ static InitSliceInfo getInitSliceInfo(MLIRContext *context,
       partialReductionMap, initOperandShape);
 }
 
+/// Returns true if `combinerOp` accumulates into `accumulator` by subtracting
+/// the reduced value from it, i.e. it reduces the negated inputs.
+static bool isSubtractingAccumulation(Operation *combinerOp,
+                                      Value accumulator) {
+  if (!isa<arith::SubFOp, arith::SubIOp>(combinerOp))
+    return false;
+  return combinerOp->getOperand(0) == accumulator;
+}
----------------
FedericoBruzzone wrote:

Although I consider this function to be well-structured, I suspect it is necessary to check the `overflow` flags for `SubIOp`. I might be missing something, what do you think? :D

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


More information about the Mlir-commits mailing list