-
Notifications
You must be signed in to change notification settings - Fork 298
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
[Seq] Canonicalize firreg with preset 0 #7350
Conversation
lib/Dialect/Seq/SeqOps.cpp
Outdated
if (!presetAttr.getValue().isZero()) | ||
return {}; |
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.
I think we can replace it with presetAttr
even when preset is not zero?
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.
You are right, addressed it.
if (constOp.getValue().isOne()) | ||
return getResetValue(); | ||
// value. Works only if no preset. | ||
if (!presetAttr) |
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 should also work fine if the preset value equals the reset value, right?
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 is actually checking if the reset signal is a constant constant high, then replace the register with the reset value. The reset value need not even be a constant. But if the reset is also a constant and its value matches with the preset, then yes we can replace it.
if (auto reset = getReset()) | ||
if (auto constOp = reset.getDefiningOp<hw::ConstantOp>()) | ||
if (constOp.getValue().isOne()) | ||
return getResetValue(); |
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.
Not directly related but I feel this canonicalization is not correct either... I think reset value needs to constant
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.
okay, seemed fine to me, according to the comments in the code. But lets investigate this further, if its legal or not.
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.
A few comments but otherwise LGTM
Canonicalize
FirReg
with a constant 0 preset. The pattern was earlier ignoring registers with any preset.This builds on #7289