[llvm] [RISCV][TTI] Implement getPartialReductionCost for the vqdotq cases (PR #140974)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Fri May 23 12:13:54 PDT 2025


================
@@ -294,6 +294,29 @@ RISCVTTIImpl::getPopcntSupport(unsigned TyWidth) const {
              : TTI::PSK_Software;
 }
 
+InstructionCost RISCVTTIImpl::getPartialReductionCost(
+    unsigned Opcode, Type *InputTypeA, Type *InputTypeB, Type *AccumType,
+    ElementCount VF, TTI::PartialReductionExtendKind OpAExtend,
+    TTI::PartialReductionExtendKind OpBExtend,
+    std::optional<unsigned> BinOp) const {
+
+  // zve32x is broken for partial_reduce_umla, but let's make sure we
+  // don't generate them.
+  if (!ST->hasStdExtZvqdotq() || ST->getELen() < 64 ||
+      Opcode != Instruction::Add || !BinOp || *BinOp != Instruction::Mul ||
----------------
lukel97 wrote:

I don't think it would unwrap the optional, the == operator should be defined between an optional and a non-optional: https://en.cppreference.com/w/cpp/utility/optional/operator_cmp

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


More information about the llvm-commits mailing list