[llvm] [LV][AArch64] Provide option to use partial reductions by default (PR #216001)

Sander de Smalen via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 27 08:25:01 PDT 2026


================
@@ -6684,10 +6684,30 @@ InstructionCost AArch64TTIImpl::getPartialReductionCost(
     return Invalid;
 
   if ((Opcode != Instruction::Add && Opcode != Instruction::Sub &&
-       Opcode != Instruction::FAdd && Opcode != Instruction::FSub) ||
-      OpAExtend == TTI::PR_None)
+       Opcode != Instruction::FAdd && Opcode != Instruction::FSub))
     return Invalid;
 
+  // We don't support 128b or higher element types.
+  if (InputTypeA->getScalarSizeInBits() > 64 ||
+      (InputTypeB && InputTypeB->getScalarSizeInBits() > 64) ||
+      AccumType->getScalarSizeInBits() > 64)
+    return Invalid;
+
+  // If none of the operands are extended and there's no extra BinOp, just
+  // cost this as the equivalent arithmetic instruction.
+  // TODO: Depending on VF and element type, we may be able to improve on this.
+  if (OpAExtend == TTI::PR_None) {
+    if (OpBExtend != TTI::PR_None || BinOp)
----------------
sdesmalen-arm wrote:

This can be simplified to:
```suggestion
    if (BinOp)
```
because OpBExtend is irrelevant when there's no binop.

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


More information about the llvm-commits mailing list