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

Tighten inferred width for PopCount #1033

Merged
merged 5 commits into from
Mar 15, 2019
Merged

Tighten inferred width for PopCount #1033

merged 5 commits into from
Mar 15, 2019

Conversation

aswaterman
Copy link
Member

An artifact of SeqUtils.count's implementation strategy makes its result one bit too wide, except for the case that the number of inputs is exactly a power of two.

count(Seq(b, c)) expands to b +& c, which is 2 bits wide, as you'd hope.

count(Seq(a, b, c)) expands to count(Seq(a)) +& count(Seq(b, c)), which is 3 bits wide, even though only 2 bits are needed to represent the result.

A simple fix is to truncate the sum at every step.

Type of change: other enhancement

Impact: API modification

Development Phase: implementation

Release Notes
Reduce width of PopCount output to minimal possible value.

@aswaterman aswaterman requested a review from a team as a code owner March 14, 2019 09:09
Copy link
Contributor

@ucbjrl ucbjrl left a comment

Choose a reason for hiding this comment

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

lgtm (and passes regression tests)

@aswaterman aswaterman merged commit cfb2f08 into master Mar 15, 2019
@aswaterman aswaterman deleted the popcount branch March 15, 2019 23:38
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