Deleted Added
full compact
1//===--- ScheduleDAGSDNodes.cpp - Implement the ScheduleDAGSDNodes class --===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//

--- 205 unchanged lines hidden (view full) ---

214
215 // Look for other loads of the same chain. Find loads that are loading from
216 // the same base pointer and different offsets.
217 SmallPtrSet<SDNode*, 16> Visited;
218 SmallVector<int64_t, 4> Offsets;
219 DenseMap<long long, SDNode*> O2SMap; // Map from offset to SDNode.
220 bool Cluster = false;
221 SDNode *Base = Node;
222 // This algorithm requires a reasonably low use count before finding a match
223 // to avoid uselessly blowing up compile time in large blocks.
224 unsigned UseCount = 0;
225 for (SDNode::use_iterator I = Chain->use_begin(), E = Chain->use_end();
223 I != E; ++I) {
226 I != E && UseCount < 100; ++I, ++UseCount) {
227 SDNode *User = *I;
228 if (User == Node || !Visited.insert(User))
229 continue;
230 int64_t Offset1, Offset2;
231 if (!TII->areLoadsFromSameBasePtr(Base, User, Offset1, Offset2) ||
232 Offset1 == Offset2)
233 // FIXME: Should be ok if they addresses are identical. But earlier
234 // optimizations really should have eliminated one of the loads.
235 continue;
236 if (O2SMap.insert(std::make_pair(Offset1, Base)).second)
237 Offsets.push_back(Offset1);
238 O2SMap.insert(std::make_pair(Offset2, User));
239 Offsets.push_back(Offset2);
240 if (Offset2 < Offset1)
241 Base = User;
242 Cluster = true;
243 // Reset UseCount to allow more matches.
244 UseCount = 0;
245 }
246
247 if (!Cluster)
248 return;
249
250 // Sort them in increasing order.
251 std::sort(Offsets.begin(), Offsets.end());
252

--- 660 unchanged lines hidden ---