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

Nicholas Guy via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 19 09:26:52 PST 2024


================
@@ -342,6 +343,62 @@ class AArch64TTIImpl : public BasicTTIImplBase<AArch64TTIImpl> {
     return BaseT::isLegalNTLoad(DataType, Alignment);
   }
 
+  InstructionCost
+  getPartialReductionCost(unsigned Opcode, Type *InputType, Type *AccumType,
+                          ElementCount VF,
+                          TTI::PartialReductionExtendKind OpAExtend,
+                          TTI::PartialReductionExtendKind OpBExtend,
+                          std::optional<unsigned> BinOp) const {
+
+    InstructionCost Invalid = InstructionCost::getInvalid();
+    InstructionCost Cost(TTI::TCC_Basic);
+
+    if (Opcode != Instruction::Add)
+      return Invalid;
+
+    EVT InputEVT = EVT::getEVT(InputType);
+    EVT AccumEVT = EVT::getEVT(AccumType);
+
+    if (VF.isScalable() && !ST->isSVEorStreamingSVEAvailable())
+      return Invalid;
+    if (VF.isFixed() && !ST->isNeonAvailable() && !ST->hasDotProd())
+      return Invalid;
+
+    // FIXME: There should be a nicer way of doing this?
----------------
NickGuy-Arm wrote:

I feel like this comment could do with some elaboration, i.e. what is "this" in this case? What is the purpose of the below code, and why is it a FIXME? These sort of questions should be answered by the comment itself, rather than having to infer from surrounding cues or github comments to figure it out (or the FIXME comment removed if it's not valuable)

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


More information about the llvm-commits mailing list