[llvm] [AArch64] Add invalid 1 x vscale costs for reductions and reduction-operations. (PR #102105)

David Green via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 7 09:22:08 PDT 2024


================
@@ -541,7 +541,15 @@ static InstructionCost getHistogramCost(const IntrinsicCostAttributes &ICA) {
 InstructionCost
 AArch64TTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
                                       TTI::TargetCostKind CostKind) {
+  // The code-generator is currently not able to handle scalable vectors
+  // of <vscale x 1 x eltty> yet, so return an invalid cost to avoid selecting
+  // it. This change will be removed when code-generation for these types is
+  // sufficiently reliable.
   auto *RetTy = ICA.getReturnType();
+  if (auto *VTy = dyn_cast<ScalableVectorType>(RetTy))
+    if (VTy->getElementCount() == ElementCount::getScalable(1))
+      return InstructionCost::getInvalid();
+
----------------
davemgreen wrote:

I was aiming for the things that we can produce a reduction from. I've added a tests for `@llvm.experimental.cttz.elts.i64.nxv1i1`, but it looks like it already produces an invalid cost before this patch. llvm.ctpop will return a vector and I couldn't see any other intrinsics that produced scalars and took vectors, which were not reductions that should be handled in another function.
We could add the extra check for the operand type too if you think that's worth-while for future-compatibility or there is another intrinsic you were thinking of.

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


More information about the llvm-commits mailing list