[PATCH] D110623: [SLP] Avoid calculating expensive spill cost when it is not required

Dinar Temirbulatov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 6 04:50:18 PST 2021


dtemirbulatov updated this revision to Diff 392024.
dtemirbulatov added a comment.

Rebased, fixed remark.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D110623/new/

https://reviews.llvm.org/D110623

Files:
  llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp


Index: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
===================================================================
--- llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -2312,6 +2312,7 @@
       // Make a new scheduling region, i.e. all existing ScheduleData is not
       // in the new region yet.
       ++SchedulingRegionID;
+      NoCalls = false;
     }
 
     ScheduleData *getScheduleData(Value *V) {
@@ -2529,6 +2530,8 @@
     // Make sure that the initial SchedulingRegionID is greater than the
     // initial SchedulingRegionID in ScheduleData (which is 0).
     int SchedulingRegionID = 1;
+
+    bool NoCalls = false;
   };
 
   /// Attaches the BlockScheduling structures to basic blocks.
@@ -5522,7 +5525,17 @@
     }
   }
 
-  InstructionCost SpillCost = getSpillCost();
+  bool NoCallInst = true;
+  for (auto &BSIter : BlocksSchedules) {
+    BlockScheduling *BS = BSIter.second.get();
+    if (!BS->NoCalls) {
+      NoCallInst = false;
+      break;
+    }
+  }
+
+  InstructionCost SpillCost = NoCallInst ? 0 : getSpillCost();
+  assert(NoCallInst ? getSpillCost() == 0 : true && "Incorrect spill cost");
   Cost += SpillCost + ExtractCost;
   if (FirstUsers.size() == 1) {
     int Limit = ShuffleMask.front().size() * 2;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110623.392024.patch
Type: text/x-patch
Size: 1305 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211206/95ec6228/attachment.bin>


More information about the llvm-commits mailing list