Keep track of bottom / top element of a set of flagged nodes.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25600 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp b/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp
index 0a4a1ac..4d7ed0a 100644
--- a/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp
+++ b/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp
@@ -86,7 +86,7 @@
       if (Op.getValueType() != MVT::Flag) break;
       // Add to node group
       NodeGroup::Add(getNI(Op.Val), NI);
-      // Let evryone else know
+      // Let everyone else know
       HasGroups = true;
     }
   }
@@ -464,6 +464,7 @@
     // Merge the two lists
     DGroup->group_insert(DGroup->group_end(),
                          UGroup->group_begin(), UGroup->group_end());
+    DGroup->Bottom = UGroup->Bottom;
   } else if (DGroup) {
     // Make user member of definers group
     U->Group = DGroup;
@@ -476,6 +477,7 @@
       DGroup->addPending(-CountInternalUses(DNI, U));
     }
     DGroup->group_push_back(U);
+    DGroup->Bottom = U;
   } else if (UGroup) {
     // Make definer member of users group
     D->Group = UGroup;
@@ -488,11 +490,14 @@
       UGroup->addPending(-CountInternalUses(D, UNI));
     }
     UGroup->group_insert(UGroup->group_begin(), D);
+    UGroup->Top    = D;
   } else {
     D->Group = U->Group = DGroup = new NodeGroup();
     DGroup->addPending(D->Node->use_size() + U->Node->use_size() -
                        CountInternalUses(D, U));
     DGroup->group_push_back(D);
     DGroup->group_push_back(U);
+    DGroup->Top    = D;
+    DGroup->Bottom = U;
   }
 }