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

Jeffrey Byrnes via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 21 14:38:50 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);
----------------
jrbyrnes wrote:

The case we care about is vector return types. These will be skipped by the early continue check and won't fall to the `getVectorInstrCost`. It seems cleaner to just add `getDataFlowCost` rather than removing the continue check.

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


More information about the llvm-commits mailing list