[llvm-branch-commits] [llvm] [LV] Add ExtNegatedMulAccReduction expression type (PR #160154)

Sander de Smalen via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Sep 23 02:30:59 PDT 2025


================
@@ -2861,12 +2861,17 @@ InstructionCost VPExpressionRecipe::computeCost(ElementCount VF,
     return Ctx.TTI.getMulAccReductionCost(false, Opcode, RedTy, SrcVecTy,
                                           Ctx.CostKind);
 
-  case ExpressionTypes::ExtMulAccReduction:
+  case ExpressionTypes::ExtNegatedMulAccReduction:
+  case ExpressionTypes::ExtMulAccReduction: {
+    if (ExpressionType == ExpressionTypes::ExtNegatedMulAccReduction &&
+        Opcode == Instruction::Add)
+      Opcode = Instruction::Sub;
----------------
sdesmalen-arm wrote:

Does it ever happen that `Opcode != Instruction::Add`? If not, this should be written as:

```suggestion
  case ExpressionTypes::ExtNegatedMulAccReduction:
      assert(Opcode == Instruction::Add && "Unexpected opcode");
      Opcode = Instruction::Sub;
      LLVM_FALLTHROUGH;
  case ExpressionTypes::ExtMulAccReduction:
```

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


More information about the llvm-branch-commits mailing list