llvm.org GIT mirror llvm / fb147de
[llvm-mca] Use a SmallVector instead of std::vector to track register reads/writes. NFCI This avoids a heap allocation most of the times. This patch gives a small but consistent 3% speedup on a release build (up to ~5% on a debug build). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@347464 91177308-0d34-0410-b5e6-96231b3b80d8 Andrea Di Biagio 9 months ago
2 changed file(s) with 11 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
2525 #endif
2626
2727 #include
28 #include
29 #include
3028
3129 namespace llvm {
3230 namespace mca {
133131 // gets notified with the actual CyclesLeft.
134132
135133 // The 'second' element of a pair is a "ReadAdvance" number of cycles.
136 std::set> Users;
134 SmallVector, 4> Users;
137135
138136 public:
139137 WriteState(const WriteDescriptor &Desc, unsigned RegID,
318316
319317 /// An instruction descriptor
320318 struct InstrDesc {
321 std::vector Writes; // Implicit writes are at the end.
322 std::vector Reads; // Implicit reads are at the end.
319 SmallVector Writes; // Implicit writes are at the end.
320 SmallVector Reads; // Implicit reads are at the end.
323321
324322 // For every resource used by an instruction of this kind, this vector
325323 // reports the number of "consumed cycles".
326 std::vector> Resources;
324 SmallVector, 4> Resources;
327325
328326 // A list of buffered resources consumed by this instruction.
329 std::vector> Buffers;
327 SmallVector> Buffers;
328
330329 unsigned MaxLatency;
331330 // Number of MicroOps for this instruction.
332331 unsigned NumMicroOps;
6464 return;
6565 }
6666
67 std::pair NewPair(User, ReadAdvance);
68 Users.insert(NewPair);
67 if (llvm::find_if(Users, [&User](const std::pair &Use) {
68 return Use.first == User;
69 }) == Users.end()) {
70 Users.emplace_back(User, ReadAdvance);
71 }
6972 }
7073
7174 void WriteState::addUser(WriteState *User) {