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

wreduce: Optimize signedness when possible #4819

Merged
merged 2 commits into from
Jan 6, 2025
Merged

Conversation

povik
Copy link
Member

@povik povik commented Dec 16, 2024

What are the reasons/motivation for this change?

See the attached test case. It can happen the RTL designer has written an explicit sign extension combined with an unsigned operation. Previously this would make wreduce unable to reduce the size of operands.

Explain how this is achieved.

We detect conditions under which the signedness of the operands is arbitrary (because the input operands are fully sized wrt to the output and the operation is one of addition, subtraction, multiplication). Under these conditions estimate the size of the reduced operator if we make the operands signed or unsigned, and then flip the signedness accordingly before the usual operand reduction of wreduce takes place.

Copy link
Collaborator

@widlarizer widlarizer left a comment

Choose a reason for hiding this comment

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

Good catch of a missed optimization, but I can't in good conscience convince myself of its correctness yet

@povik povik requested a review from widlarizer January 3, 2025 12:08
Copy link
Member

@clairexen clairexen left a comment

Choose a reason for hiding this comment

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

Noice! (LGTM)

@povik
Copy link
Member Author

povik commented Jan 6, 2025

Thanks Claire!

@povik povik merged commit 41e4aa8 into YosysHQ:main Jan 6, 2025
44 checks passed
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