[llvm] [LoopVectorizer] Add support for partial reductions (PR #92418)

Graham Hunter via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 5 06:41:27 PDT 2024


================
@@ -1246,6 +1246,12 @@ class TargetTransformInfo {
   /// \return if target want to issue a prefetch in address space \p AS.
   bool shouldPrefetchAddressSpace(unsigned AS) const;
 
+  bool isPartialReductionSupported(const Instruction *ReductionInstr,
----------------
huntergr-arm wrote:

This feels a little overfitted to the integer DOT products, and could be a little more generic. We could also have it help with cost modelling, returning InstructionCost::Invalid to indicate the operation isn't supported with the stated types and VF.

Perhaps something like:

```
enum PartialReductionExtendKind {
  PR_None,
  PR_SignExtend,
  PR_ZeroExtend,
  // Others in future, like fp converts?
}

InstructionCost getPartialReductionCost(unsigned Opcode, Type *InputType, Type *AccumType, ElementCount VF, PartialReductionExtendKind OpAExtend, PartialReductionExtendKind OpBExtend, std::optional<unsigned> BinOp = std::nullopt);
```

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


More information about the llvm-commits mailing list