Skip to content
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

Merged
merged 6 commits into from
Jul 19, 2024
Merged

Conversation

prithayan
Copy link
Contributor

@prithayan prithayan commented Jul 19, 2024

Canonicalize FirReg with a constant 0 preset. The pattern was earlier ignoring registers with any preset.

This builds on #7289

Comment on lines 704 to 705
if (!presetAttr.getValue().isZero())
return {};
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 we can replace it with presetAttr even when preset is not zero?

Copy link
Contributor Author

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)

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?

Copy link
Contributor Author

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.

Comment on lines +673 to +676
if (auto reset = getReset())
if (auto constOp = reset.getDefiningOp<hw::ConstantOp>())
if (constOp.getValue().isOne())
return getResetValue();
Copy link
Member

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

Copy link
Contributor Author

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.

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.

A few comments but otherwise LGTM

@prithayan prithayan merged commit dde9f4b into main Jul 19, 2024
4 checks passed
@prithayan prithayan deleted the dev/pbarua/firreg-preset-canon branch July 19, 2024 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants