-
Notifications
You must be signed in to change notification settings - Fork 304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FIRRTL] FoldUnusedBits: minor cleanup #7914
Conversation
Once the memory has been replaced with the compressed memory, a lot of the bitselect ops reading from the old memory will be selecting the entire memory. Use createOrFold to eagerly clean up these "whole range bitselect" ops.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
if (!bits) { | ||
usedBits.set(); | ||
continue; | ||
} | ||
if (!bits) | ||
return failure(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This early exit makes sense to me. No reason to wait until all users have been visited before bailing.
rewriter.replaceOpWithNewOp<BitsPrimOp>( | ||
readOp, readOp.getInput(), | ||
// Create a new bit selection from the compressed memory. The new op may | ||
// be folded if we are selecting the entire compressed memory. | ||
auto newReadValue = rewriter.createOrFold<BitsPrimOp>( | ||
readOp.getLoc(), readOp.getInput(), | ||
readOp.getHi() - readOp.getLo() + it->second, it->second); | ||
rewriter.replaceAllUsesWith(readOp, newReadValue); | ||
rewriter.eraseOp(readOp); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to me.
Two changes: