Skip to content

Conversation

@fabianschuiki
Copy link
Contributor

@fabianschuiki fabianschuiki commented Sep 10, 2025

Use a stable sort in the reducer to sort matches. The binary search over the matchese expects them to be in the order that they were matched in the IR when matches have the same benefit.

Add a generic reduction to prune unused symbols.

Make the FIRRTL annotation remover check if annotations are already empty, and not match on those ops. This significantly improves reduction speed.

Fix an issue in the FIRRTL module externalizer, where FExtModules require an additional list of known layers that needs to be created. Also, don't externalize modules that participate in NLAs, since removing those would invalidate the NLA.

@fabianschuiki fabianschuiki added FIRRTL Involving the `firrtl` dialect Reducer Related to `circt-reduce` labels Sep 10, 2025
@fabianschuiki fabianschuiki force-pushed the fschuiki/firrtl-reduce-tweaks branch from 005d953 to 76921bb Compare September 10, 2025 18:52
@fabianschuiki fabianschuiki changed the title [FIRRTL] Improve annotation remover and module externalizer reductions [Reduce] Use stable sort, prune unused symbols, tweak FIRRTL reductions Sep 10, 2025
@fabianschuiki fabianschuiki force-pushed the fschuiki/firrtl-reduce-tweaks branch from 76921bb to 3eef93c Compare September 10, 2025 20:39
if (minChunks > 0)
rangeLength = std::min<size_t>(rangeLength,
std::max<size_t>(opIdx / minChunks, 1));
rangeLength = std::min<size_t>(
Copy link
Member

@uenoku uenoku Sep 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you use std::clamp and llvm::divideCeil?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, let me tweak that! 👍

Use a stable sort in the reducer to sort matches. The binary search over
the matchese expects them to be in the order that they were matched in
the IR when matches have the same benefit.

Add a generic reduction to prune unused symbols.

Make the FIRRTL annotation remover check if annotations are already
empty, and not match on those ops. This significantly improves reduction
speed.

Fix an issue in the FIRRTL module externalizer, where `FExtModule`s
require an additional list of known layers that needs to be created.
Also, don't externalize modules that participate in NLAs, since removing
those would invalidate the NLA.
@fabianschuiki fabianschuiki force-pushed the fschuiki/firrtl-reduce-tweaks branch from 3eef93c to c8ac3ee Compare September 10, 2025 22:54
@fabianschuiki fabianschuiki merged commit 21eb57a into main Sep 10, 2025
7 checks passed
@fabianschuiki fabianschuiki deleted the fschuiki/firrtl-reduce-tweaks branch September 10, 2025 23:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

FIRRTL Involving the `firrtl` dialect Reducer Related to `circt-reduce`

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants