-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Add x86 intrinsics for bit manipulation (BMI 1.0, BMI 2.0, and TBM). #34412
Add x86 intrinsics for bit manipulation (BMI 1.0, BMI 2.0, and TBM). #34412
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @nikomatsakis (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
…0, BMI 2.0, and TBM.
7ee154e
to
483bec7
Compare
I don' have access to all the platforms that the SIMD crate supports. Is there a better way to test it than compiling the SIMD crate for all the platforms it supports? |
@huonw you used to work on the SIMD crate, any ideas about how to test it? Ping: @ranma42 @brson @alexcrichton |
Might be good to get some more eyes on this still. Previous issue didn't generate much discussion. Niko's on vacation. r? @nrc |
Currently the |
I like the looks of this PR. I'm not sure about the second commit - I don't understand the issues there. So, r? @alexcrichton |
It is what @alexcrichton mentioned above, the I could probably have used The second commit allows having differently named instruction sets per platform, e.g.,
While |
Discussed during the libs triage meeting yesterday, the conclusion was that this is fine to merge, thanks for the PR @gnzlbg! We're in general pretty amenable to adding any support for fancy intrinsics like this, although we'd be much more hesitant about adding bits and pieces to the standard library, but that's not happening here! |
⌛ Testing commit 483bec7 with merge 849864d... |
💔 Test failed - auto-linux-64-x-android-t |
It's my first PR so I don't really know what to look for in the build logs yet to figure out what failed, but this looks like some sort of time out while compiling. |
Ah no worries that just means that the Android build timed out, which is unlikely to be related to this patch. so let's just... @bors: retry |
Maybe I did something wrong? |
Oh nah this PR is fine, we're just having a lot of automation trouble lately apparently so it may take awhile for bors to get around to this PR |
⌛ Testing commit 483bec7 with merge 7e269b2... |
💔 Test failed - auto-win-msvc-64-opt-rustbuild |
@bors: retry |
⌛ Testing commit 483bec7 with merge f8be993... |
💔 Test failed - auto-win-msvc-64-opt-rustbuild |
@bors: retry |
1 similar comment
@bors: retry |
…r=alexcrichton Add x86 intrinsics for bit manipulation (BMI 1.0, BMI 2.0, and TBM). This PR adds the LLVM x86 intrinsics for the bit manipulation instruction sets (BMI 1.0, BMI 2.0, and TBM). The objective of this pull-request is to allow building a library that implements all the algorithms offered by those instruction sets, using compiler intrinsics for the targets that support them (by means of `target_feature`). The target features added are: - `bmi`: Bit Manipulation Instruction Set 1.0, available in Intel >= Haswell and AMD's >= Jaguar/Piledriver, - `bmi2`: Bit Manipulation Instruction Set 2.0, available in Intel >= Haswell and AMD's >= Excavator, - `tbm`: Trailing Bit Manipulation, available only in AMD's Piledriver (won't be available in newer CPUs). The intrinsics added are: - BMI 1.0: - `bextr`: Bit field extract (with register). - BMI 2.0: - `bzhi`: Zero high bits starting with specified bit position. - `pdep`: Parallel bits deposit. - `pext`: Parallel bits extract. - TBM: - `bextri`: Bit field extract (with immediate).
This PR adds the LLVM x86 intrinsics for the bit manipulation instruction sets (BMI 1.0, BMI 2.0, and TBM).
The objective of this pull-request is to allow building a library that implements all the algorithms offered by those instruction sets, using compiler intrinsics for the targets that support them (by means of
target_feature
).The target features added are:
bmi
: Bit Manipulation Instruction Set 1.0, available in Intel >= Haswell and AMD's >= Jaguar/Piledriver,bmi2
: Bit Manipulation Instruction Set 2.0, available in Intel >= Haswell and AMD's >= Excavator,tbm
: Trailing Bit Manipulation, available only in AMD's Piledriver (won't be available in newer CPUs).The intrinsics added are:
bextr
: Bit field extract (with register).bzhi
: Zero high bits starting with specified bit position.pdep
: Parallel bits deposit.pext
: Parallel bits extract.bextri
: Bit field extract (with immediate).