Skip to content

Plural right shift #91

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

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open

Plural right shift #91

wants to merge 26 commits into from

Conversation

jamierpond
Copy link
Collaborator

@jamierpond jamierpond commented Jun 5, 2024

Now is correct. Godbolt for your amusement. https://godbolt.org/z/T51GPhT8M

Generate the smallest mask required to blit out the overflow using (2^shift_size - 1) which basially transforms shift size into a tally representation of itself in binary. Such that 2 -> 11; 3 -> 111; 4 -> 1111; etc. This then only requires the lane index mask and a shift, then or'ing it all back into the result.

@jamierpond jamierpond changed the title Plural right lane shift Plural right shift Jun 5, 2024
@jamierpond jamierpond marked this pull request as ready for review June 5, 2024 03:54
@jamierpond jamierpond marked this pull request as draft June 5, 2024 04:00
@jamierpond jamierpond marked this pull request as ready for review June 5, 2024 04:57
#include "zoo/swar/SWAR.h"
#include <cstdint>
Copy link
Owner

Choose a reason for hiding this comment

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

?

Comment on lines +265 to +266
B val = msb.value() >> (NB - 1);
auto msbCopiedToLSB = S{val};
Copy link
Owner

Choose a reason for hiding this comment

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

Why this change?

Comment on lines +430 to +431
T res = msbCleared.value() << 1;
return S{res};
Copy link
Owner

Choose a reason for hiding this comment

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

Why so many unnecessary changes?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

was getting seemingly random type errors.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

will try and resolve

Comment on lines 498 to 499
/** Transforms a number into a number into a binary tally.
* E.g. 0b0011 (3) -> 0b0111
Copy link
Owner

Choose a reason for hiding this comment

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

You seem to mean this converts a binary to an unary

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes lol thank you.

Comment on lines 509 to 513
static_assert(base2TallyTransform_Plural(S{0b0001'0010'0011'0011}).value() == 0b0001'0011'0111'0111);
static_assert(base2TallyTransform_Plural(S{0b0000'0001'0010'0011}).value() == 0b0000'0001'0011'0111);
static_assert(base2TallyTransform_Plural(S{0b0100'0001'0010'0011}).value() == 0b1111'0001'0011'0111);
static_assert(base2TallyTransform_Plural(S{0b0000'0000'0000'0001}).value() == 0b0000'0000'0000'0001);
static_assert(base2TallyTransform_Plural(SWAR<8, uint16_t>{0b000000111'00000101}).value() == 0b01111111'00011111); // 7 -> 5
Copy link
Owner

Choose a reason for hiding this comment

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

Use whitespace to make the point of the comparison/test evident!
You not only trample the whitespace of others, but fail to use it

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.

2 participants