[PATCH] D59722: [ScheduleDAG] Avoid unnecessary recomputation of topological order.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun May 31 03:43:45 PDT 2020


This revision was not accepted when it landed; it landed in state "Changes Planned".
This revision was automatically updated to reflect the committed changes.
Closed by commit rGec25a71eb7fc: [ScheduleDAG] Avoid unnecessary recomputation of topological order. (authored by fhahn).

Changed prior to commit:
  https://reviews.llvm.org/D59722?vs=191956&id=267494#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59722

Files:
  llvm/include/llvm/CodeGen/ScheduleDAG.h
  llvm/lib/CodeGen/ScheduleDAG.cpp
  llvm/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp


Index: llvm/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp
+++ llvm/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp
@@ -279,7 +279,7 @@
     SUnit *NewNode = newSUnit(N);
     // Update the topological ordering.
     if (NewNode->NodeNum >= NumSUnits)
-      Topo.MarkDirty();
+      Topo.AddSUnitWithoutPredecessors(NewNode);
     return NewNode;
   }
 
@@ -289,7 +289,7 @@
     SUnit *NewNode = Clone(N);
     // Update the topological ordering.
     if (NewNode->NodeNum >= NumSUnits)
-      Topo.MarkDirty();
+      Topo.AddSUnitWithoutPredecessors(NewNode);
     return NewNode;
   }
 
Index: llvm/lib/CodeGen/ScheduleDAG.cpp
===================================================================
--- llvm/lib/CodeGen/ScheduleDAG.cpp
+++ llvm/lib/CodeGen/ScheduleDAG.cpp
@@ -713,6 +713,14 @@
   return false;
 }
 
+void ScheduleDAGTopologicalSort::AddSUnitWithoutPredecessors(const SUnit *SU) {
+  assert(SU->NodeNum == Index2Node.size() && "Node cannot be added at the end");
+  assert(SU->NumPreds == 0 && "Can only add SU's with no predecessors");
+  Node2Index.push_back(Index2Node.size());
+  Index2Node.push_back(SU->NodeNum);
+  Visited.resize(Node2Index.size());
+}
+
 bool ScheduleDAGTopologicalSort::IsReachable(const SUnit *SU,
                                              const SUnit *TargetSU) {
   FixOrder();
Index: llvm/include/llvm/CodeGen/ScheduleDAG.h
===================================================================
--- llvm/include/llvm/CodeGen/ScheduleDAG.h
+++ llvm/include/llvm/CodeGen/ScheduleDAG.h
@@ -724,6 +724,10 @@
   public:
     ScheduleDAGTopologicalSort(std::vector<SUnit> &SUnits, SUnit *ExitSU);
 
+    /// Add a SUnit without predecessors to the end of the topological order. It
+    /// also must be the first new node added to the DAG.
+    void AddSUnitWithoutPredecessors(const SUnit *SU);
+
     /// Creates the initial topological ordering from the DAG to be scheduled.
     void InitDAGTopologicalSorting();
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59722.267494.patch
Type: text/x-patch
Size: 2083 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200531/194e48a4/attachment.bin>


More information about the llvm-commits mailing list