[llvm] [SLP]: Introduce and use getDataFlowCost (PR #112999)

Alexey Bataev via llvm-commits llvm-commits at lists.llvm.org
Sat Oct 19 10:20:06 PDT 2024


================
@@ -10257,15 +10328,24 @@ InstructionCost BoUpSLP::getTreeCost(ArrayRef<Value *> VectorizedVals) {
   for (ExternalUser &EU : ExternalUses) {
     // We only add extract cost once for the same scalar.
     if (!isa_and_nonnull<InsertElementInst>(EU.User) &&
-        !ExtractCostCalculated.insert(EU.Scalar).second)
+        !ExtractCostCalculated.insert(EU.Scalar).second) {
       continue;
+    }
 
     // Uses by ephemeral values are free (because the ephemeral value will be
     // removed prior to code generation, and so the extraction will be
     // removed as well).
     if (EphValues.count(EU.User))
       continue;
 
+    // Account for any additional costs required by CallingConvention for the
+    // type.
+    if (isa_and_nonnull<ReturnInst>(EU.User)) {
+      Cost +=
+          TTI->getDataFlowCost(EU.Scalar->getType(), /*IsCallingConv*/ true);
----------------
alexey-bataev wrote:

No need to add it here, you can check it in getVectorInstrCost, just need to pass an extra info about the user instruction, if needed

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


More information about the llvm-commits mailing list