[llvm] Add proper cost computation for llvm.vector.reduce.add (PR #77764)

via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 11 05:21:42 PST 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 40d5c2bcd41a534e6bab98fedf1a930d9bd165e7 65811b9c06670a6f544ac1363ebaac33a189b8ab -- llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp b/llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp
index d8a0923ab9..ad7684a1c2 100644
--- a/llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp
@@ -1244,19 +1244,29 @@ InstructionCost SystemZTTIImpl::getInterleavedMemoryOpCost(
   return NumVectorMemOps + NumPermutes;
 }
 
-static int getVectorIntrinsicInstrCost(Intrinsic::ID ID, Type *RetTy, const SmallVectorImpl<Type *>& ParamTys) {
-  dbgs() << "getVectorIntrinsicInstrCost entry, ID == " << ID << ", name = " << Intrinsic::getName(ID) << ", compare with " << Intrinsic::getName(Intrinsic::vector_reduce_add) << "(" << Intrinsic::vector_reduce_add << ")\n";
+static int
+getVectorIntrinsicInstrCost(Intrinsic::ID ID, Type *RetTy,
+                            const SmallVectorImpl<Type *> &ParamTys) {
+  dbgs() << "getVectorIntrinsicInstrCost entry, ID == " << ID
+         << ", name = " << Intrinsic::getName(ID) << ", compare with "
+         << Intrinsic::getName(Intrinsic::vector_reduce_add) << "("
+         << Intrinsic::vector_reduce_add << ")\n";
   if (RetTy->isVectorTy() && ID == Intrinsic::bswap)
     return getNumVectorRegs(RetTy); // VPERM
   else if (ID == Intrinsic::vector_reduce_add) {
     dbgs() << "getVectorIntrinsicInstrCost is reduce_add intrinsic\n";
     auto *VTy = cast<FixedVectorType>(ParamTys.front());
     switch (VTy->getNumElements()) {
-      default: return -1;
-      case 2: return 3;
-      case 4: return 5;
-      case 8: return 7;
-      case 16: return 11;
+    default:
+      return -1;
+    case 2:
+      return 3;
+    case 4:
+      return 5;
+    case 8:
+      return 7;
+    case 16:
+      return 11;
     }
   }
   return -1;
@@ -1265,8 +1275,8 @@ static int getVectorIntrinsicInstrCost(Intrinsic::ID ID, Type *RetTy, const Smal
 InstructionCost
 SystemZTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
                                       TTI::TargetCostKind CostKind) {
-  InstructionCost Cost =
-      getVectorIntrinsicInstrCost(ICA.getID(), ICA.getReturnType(), ICA.getArgTypes());
+  InstructionCost Cost = getVectorIntrinsicInstrCost(
+      ICA.getID(), ICA.getReturnType(), ICA.getArgTypes());
   if (Cost != -1)
     return Cost;
   return BaseT::getIntrinsicInstrCost(ICA, CostKind);

``````````

</details>


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


More information about the llvm-commits mailing list