diff --git a/llvm/include/llvm/CodeGen/ResourceScoreboard.h b/llvm/include/llvm/CodeGen/ResourceScoreboard.h index b6ca270dfd20..180ff86b4768 100644 --- a/llvm/include/llvm/CodeGen/ResourceScoreboard.h +++ b/llvm/include/llvm/CodeGen/ResourceScoreboard.h @@ -64,12 +64,16 @@ template class ResourceScoreboard { RC &operator[](int Cycle) { return Cycles[(Head + Cycle) & (Size - 1)]; } void reset(int D = 1) { + // Implementation relies on masking to wrap-around, so round up + // to a power of two. + int Pow2 = 1; + while (Pow2 < D) { + Pow2 += Pow2; + } if (Cycles.empty()) { - Depth = D; + Depth = Pow2; Size = 2 * Depth; } - // Check for a power of two - assert((Size & (Size - 1)) == 0); Cycles.clear(); Cycles.resize(Size); Head = 0; @@ -151,6 +155,21 @@ template class ResourceScoreboard { dbgs() << "+ " << Repeats << " more\n"; } } + + // Print the full scoreboard . + void dumpFull() const { + int First = firstOccupied(); + int Last = lastOccupied(); + for (int C = First; C <= Last; C++) { + const RC &Cycle = (*this)[C]; + if (C == 0) { + dbgs() << ">"; + } + dbgs() << "\t"; + Cycle.dump(); + dbgs() << "\n"; + } + } }; } // end namespace llvm diff --git a/llvm/lib/Target/AIE/AIEHazardRecognizer.cpp b/llvm/lib/Target/AIE/AIEHazardRecognizer.cpp index 63fee9c4f2c3..88ef2a22a2bf 100644 --- a/llvm/lib/Target/AIE/AIEHazardRecognizer.cpp +++ b/llvm/lib/Target/AIE/AIEHazardRecognizer.cpp @@ -599,14 +599,7 @@ unsigned AIEHazardRecognizer::computeScoreboardDepth() const { return 0; } - Depth = std::max(Depth, UserScoreboardDepth.getValue()); - - // Find the next power-of-2 >= Depth - unsigned ScoreboardDepth = 1; - while (ScoreboardDepth < Depth) { - ScoreboardDepth *= 2; - } - return ScoreboardDepth; + return std::max(Depth, UserScoreboardDepth.getValue()); } std::optional