Skip to content

Commit 3f745e7

Browse files
oharboeclaude
andcommitted
rsz: use cell id() tie-break for stable buffer-size sort
Per review, tie-break on LibertyCell::id() rather than the cell name: an integer compare instead of constructing a string per comparison. This matches the existing buffer comparator in Resizer.cc (findFastBuffers), which already tie-breaks equal-key cells on id(). String compares are the most expensive tie-break. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
1 parent e988998 commit 3f745e7

2 files changed

Lines changed: 6 additions & 17 deletions

File tree

src/rsz/src/Rebuffer.cc

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1500,15 +1500,10 @@ void Rebuffer::init()
15001500
}
15011501

15021502
std::ranges::sort(buffer_sizes_, [=](BufferSize a, BufferSize b) {
1503-
const float cin_a = bufferCin(a.cell), cin_b = bufferCin(b.cell);
1504-
if (cin_a < cin_b) {
1505-
return true;
1506-
}
1507-
if (cin_b < cin_a) {
1508-
return false;
1503+
if (bufferCin(a.cell) != bufferCin(b.cell)) {
1504+
return bufferCin(a.cell) < bufferCin(b.cell);
15091505
}
1510-
// buffer_fast_sizes_ is unordered; tie-break for stable output.
1511-
return std::string_view(a.cell->name()) < std::string_view(b.cell->name());
1506+
return a.cell->id() < b.cell->id();
15121507
});
15131508

15141509
buffer_sizes_index_.clear();

src/rsz/src/RepairDesign.cc

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -647,16 +647,10 @@ void RepairDesign::findBufferSizes()
647647
resizer_->buffer_fast_sizes_.end()};
648648
std::ranges::sort(buffer_sizes_,
649649
[=](sta::LibertyCell* a, sta::LibertyCell* b) {
650-
const float cin_a = bufferCin(a), cin_b = bufferCin(b);
651-
if (cin_a < cin_b) {
652-
return true;
650+
if (bufferCin(a) != bufferCin(b)) {
651+
return bufferCin(a) < bufferCin(b);
653652
}
654-
if (cin_b < cin_a) {
655-
return false;
656-
}
657-
// buffer_fast_sizes_ is unordered; tie-break for stable
658-
// output.
659-
return std::string_view(a->name()) < std::string_view(b->name());
653+
return a->id() < b->id();
660654
});
661655
}
662656

0 commit comments

Comments
 (0)