Skip to content

Conversation

fabianschuiki
Copy link
Contributor

Extend the Sig2Reg LLHD pass to completely remove a signal and all its associated drives if the signal is only driven, but never probe or used in any other way.

Copy link
Member

@uenoku uenoku left a comment

Choose a reason for hiding this comment

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

LGTM. Could you add this as canonicalization as well in a follow-up?

})) {
LLVM_DEBUG(llvm::dbgs() << " - Removing drive-only signal "
<< sigOp.getName() << "\n");
for (auto *user : sigOp->getUsers())
Copy link
Member

Choose a reason for hiding this comment

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

I think early increment is necessary

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 catch, thanks! 👍

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!

Could you add this as canonicalization as well in a follow-up?

This pass currently assumes that you don't care about tracking signals by their name afterward (e.g., in simulation). I don't think we want this by default in canonicalization. We might even want to add an option to this pass to insert hw.wire or similar operations to the promoted SSA values to keep the name references in the future.

@fabianschuiki
Copy link
Contributor Author

@uenoku @maerhart Do you remember what our stance was on canonicalizer complexity? Replacing signals with the driven value would be nice to have as a canonicalization, but I remember discussing that walking all users of an op in a canonicalizer might be too costly -- is that a "policy" we settled on?

Extend the Sig2Reg LLHD pass to completely remove a signal and all its
associated drives if the signal is only driven, but never probe or used
in any other way.
@fabianschuiki fabianschuiki force-pushed the fschuiki/remove-drive-only-signals branch from 17ae22b to 1ec6a13 Compare July 1, 2025 15:36
@fabianschuiki fabianschuiki merged commit 5f87d2a into main Jul 1, 2025
7 checks passed
@fabianschuiki fabianschuiki deleted the fschuiki/remove-drive-only-signals branch July 1, 2025 16:01
TaoBi22 pushed a commit to TaoBi22/circt that referenced this pull request Jul 17, 2025
Extend the Sig2Reg LLHD pass to completely remove a signal and all its
associated drives if the signal is only driven, but never probe or used
in any other way.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants