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

Correct lzcnt results #1108

Merged
merged 11 commits into from
Aug 1, 2020
Merged

Correct lzcnt results #1108

merged 11 commits into from
Aug 1, 2020

Conversation

AlexGuteniev
Copy link
Contributor

@AlexGuteniev AlexGuteniev commented Jul 29, 2020

Fixes #1103

@AlexGuteniev AlexGuteniev requested a review from a team as a code owner July 29, 2020 19:52
stl/inc/bit Outdated Show resolved Hide resolved
@StephanTLavavej StephanTLavavej added the bug Something isn't working label Jul 30, 2020
@AlexGuteniev AlexGuteniev marked this pull request as draft July 30, 2020 03:30
@AlexGuteniev AlexGuteniev marked this pull request as ready for review July 30, 2020 03:47
Copy link
Member

@StephanTLavavej StephanTLavavej left a comment

Choose a reason for hiding this comment

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

Looks great, just a couple of questions about naming. If you or @fsb4000 can confirm that the tests for countl_zero fail on the affected processors before your change, and pass after, I think that should be sufficient for validation. (Note that you can compile a test program on one machine and just copy it to another if you statically link.)

stl/inc/bit Outdated Show resolved Hide resolved
stl/inc/bit Outdated Show resolved Hide resolved
stl/inc/bit Outdated Show resolved Hide resolved
@fsb4000
Copy link
Contributor

fsb4000 commented Jul 30, 2020

If you or @fsb4000 can confirm that the tests for countl_zero fail on the affected processors before your change, and pass after, I think that should be sufficient for validation.

On my CPU(AMD FX8300) both versions(current master and the pull request) print same(correct) result:

test

@AlexGuteniev
Copy link
Contributor Author

I confirm the fix on pre AMB-LZCNT-POPCNT machine

@StephanTLavavej
Copy link
Member

Thanks @fsb4000 and @AlexGuteniev! I think this all makes sense - the FX-8300 worked because it physically supported Advanced Bit Manipulation, so the previous code said "oh, this doesn't support AVX2, we need to special-case 0" but otherwise used lzcnt which works. The test previously failed on Alex's even older processor which doesn't physically support lzcnt.

@barcharcraz
Copy link
Member

it sucks that we can't test this by modifying __isa_available before running the functions.

Copy link
Member

@barcharcraz barcharcraz left a comment

Choose a reason for hiding this comment

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

approved with a testing suggestion, I don't feel that suggestion should block merging this though.

stl/inc/bit Show resolved Hide resolved
stl/inc/bit Show resolved Hide resolved
@StephanTLavavej
Copy link
Member

Thanks @statementreply for noticing this bug, @AlexGuteniev for fixing it, and @fsb4000 for helping to validate the fix! 😺 😸 🐈

@AlexGuteniev AlexGuteniev deleted the lzcnt branch August 2, 2020 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

<bit>: Concern about lzcnt used as bsr correctness
4 participants