Optimize 64-bit int<->float conversions on AVX2, add more tests - #348
Merged
Shnatsel merged 4 commits intoAug 25, 2026
Merged
Conversation
LaurenzV
approved these changes
Aug 25, 2026
LaurenzV
left a comment
Collaborator
There was a problem hiding this comment.
As you already know I'm not a huge fan of big tests with large loops and magic numbers, but if you think it makes sense then let's just keep it. 😄
Contributor
Author
|
Yeah, sorry, these are kind of necessary. 64 bits is a very large input space, so throwing a bunch of handwritten inputs at it isn't very useful, and you can't write a simple exhaustive test either (which works fine for 32 bits). I'd rather verify the edge cases like this than ship a buggy implementation accidentally. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #311
Summary:
_mm_cvttsd_si64which is faster than SIMD formulations thanks to ILP (for 2-element vectors only) and cheaper thanascasts thanks to not handling saturationllvm-mca reciprocal throughput for 256-bit vectors on AVX2, lower is better:
Up to 8x speedup!
Also adds in-depth tests for various edge cases against a from-scratch integer-only reference implementation because I don't trust anything anymore after the libm and musl FMA fiasco, and testing an algorithm from LLVM against itself is silly.