Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@fabianschuiki
Copy link
Contributor

The HW reductions that replace values with constants and remove module ports are beneficial even when they increase the size of the MLIR text. Removing ports and replacing values with zero removes dependencies in the IR, making it easier to apply other reductions.

Make these reductions return true from acceptSizeIncrease to have the reducer accept the result even if the module size increases.

@fabianschuiki fabianschuiki added HW Involving the `hw` dialect Reducer Related to `circt-reduce` labels Aug 13, 2025
Copy link
Member

@maerhart maerhart left a comment

Choose a reason for hiding this comment

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

LGTM

In what situations can removing ports lead to an increase? Are we not counting block arguments?

@fabianschuiki fabianschuiki force-pushed the fschuiki/always-constantify branch from 87d3359 to a3a042c Compare August 13, 2025 16:22
@fabianschuiki fabianschuiki force-pushed the fschuiki/multi-port-pruner branch from 5ba59c2 to 571fd3b Compare August 13, 2025 16:22
@fabianschuiki
Copy link
Contributor Author

Yeah good point, the port reduction should always reduce the module size. I marked them here as well since they are always beneficial, so accepting them should not be contingent on module size.

struct HWConstantifier : public Reduction {
void matches(Operation *op,
llvm::function_ref<void(uint64_t, uint64_t)> addMatch) override {
if (op->hasTrait<OpTrait::ConstantLike>())
Copy link
Contributor

Choose a reason for hiding this comment

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

--> don't try to constant-ify something already a constant? ✅

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Exactly 😁

Base automatically changed from fschuiki/multi-port-pruner to main August 13, 2025 17:27
The HW reductions that replace values with constants and remove module
ports are beneficial even when they increase the size of the MLIR text.
Removing ports and replacing values with zero removes dependencies in
the IR, making it easier to apply other reductions.

Make these reductions return true from `acceptSizeIncrease` to have the
reducer accept the result even if the module size increases.
@fabianschuiki fabianschuiki force-pushed the fschuiki/always-constantify branch from a3a042c to 259ca33 Compare August 13, 2025 17:28
@fabianschuiki fabianschuiki merged commit 025dbda into main Aug 13, 2025
7 checks passed
@fabianschuiki fabianschuiki deleted the fschuiki/always-constantify branch August 13, 2025 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

HW Involving the `hw` dialect Reducer Related to `circt-reduce`

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants