-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
breaking: polish @clz() @ctz() @popcount() @bswap() @bitReverse() #2134
Conversation
Why are the new files added? |
Whoops, thanks for spotting that. |
7e25928
to
a401388
Compare
I'm now working on exanding the vector features sufficiently to get this algorithm ported to zig https://github.com/cyb70289/utf8 using llvm vectors, rather than assembly intrinsics. |
f1c765d
to
157ade9
Compare
…d add @fshl() and @fshr() Closes: ziglang#2119 breaking: @bitreverse -> @bitreverse, @bswap -> @bswap Closes: ziglang#2120 Comes with tests The implicit casting fixups are not in here due to technical issues. see ziglang#2121
The optimizer can only optimize that code if it can guarantee that source and dest do not overlap.
…int_fits_in_bits code Also fix a few nasty bugs in bigint_fits_in_bits, such as handling of the value 0.
Some platforms don't support vectors, and it should be easy to skip these tests for those platforms
3e43f36
to
c005271
Compare
no safety checks no 0-width type support
c005271
to
1430867
Compare
Also, change the interface to accept an appropiately ranged type. While this is technically breaking, no users used this useless feature.
var neg32: i32 = -16773785; | ||
expect(@bitreverse(i32, -16773785) == @bitreverse(i32, neg32)); | ||
var neg40: i40 = minInt(i40) + 12345; | ||
expect(@bitreverse(i40, minInt(i40) + 12345) == @bitreverse(i40, neg40)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why remove these?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because they are tautologies. They are not testing bitreverse.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the time that code was written, I'm not sure about now, the comment at the top of the block explained correctly what was happening. The LHS values were calculated by comptime code in the Zig compiler while the RHS values are calculated on the LLVM side. These tests were used to make sure the two match.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vegecode is correct, and it's still true. @bitreverse(i32, -16773785)
exercises comptime evaluation; @bitreverse(i32, neg32)
with neg32
as a var
exercises runtime evaluation.
1292aa0
to
e90f46e
Compare
This is too much. I can't keep up with this ever-growing pull request. @shawnl I need you to make one pull request at a time, which only tackles one thing. |
Closes: #2119
breaking: @bitreverse -> @bitreverse, @bswap -> @bswap
Closes: #2120
Comes with tests
OK. This has changed quite a bit since it was opened. It gained
@fshl
and@fshr
, and then I added@memMove
and merged a differn't pull request so I could flesh out@memMove
. I am working on #767