[llvm] [SystemZ] Add custom handling of legal vectors with reduce-add. (PR #88495)
Dominik Steenken via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 12 05:52:03 PDT 2024
================
@@ -1326,3 +1323,31 @@ SystemZTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
return Cost;
return BaseT::getIntrinsicInstrCost(ICA, CostKind);
}
+
+bool SystemZTTIImpl::shouldExpandReduction(const IntrinsicInst *II) const {
+ // Always expand on Subtargets without vector instructions
+ if (!ST->hasVector())
+ return true;
+
+ // Always expand for operands that do not fill one vector reg
+ auto *Type = cast<FixedVectorType>(II->getOperand(0)->getType());
+ unsigned NumElts = Type->getNumElements();
+ unsigned ScalarSize = Type->getScalarSizeInBits();
+ unsigned MaxElts = SystemZ::VectorBits / ScalarSize;
+ if (NumElts < MaxElts)
+ return true;
+
+ // Otherwise
+ switch (II->getIntrinsicID()) {
+ // Do not expand vector.reduce.add
+ case Intrinsic::vector_reduce_add:
+ // Except for i64, since the performance benefit is dubious there
+ if (ScalarSize < 64) {
+ return false;
+ } else {
+ return true;
+ }
----------------
dominik-steenken wrote:
Agreed. that's definitely clearer.
https://github.com/llvm/llvm-project/pull/88495
More information about the llvm-commits
mailing list