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

Alexey Bataev via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 21 15:35:36 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:

This code does not check for vector return type, it is externally used scalar. What exactly do you want to calculate here: the cost of passing value, returned by extractelement instruction, or the cost of vectorized buildvector (replaced by shuffles or just original vectors in case of the identity shuffle)?

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


More information about the llvm-commits mailing list