Thanks to visit codestin.com
Credit goes to github.com

Skip to content

HW Intrinsics: Add BSR, BSF, and BSWAP intrinsics #10741

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

Closed
Zhentar opened this issue Jul 21, 2018 · 4 comments
Closed

HW Intrinsics: Add BSR, BSF, and BSWAP intrinsics #10741

Zhentar opened this issue Jul 21, 2018 · 4 comments
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI enhancement Product code improvement that does NOT require public API changes/additions
Milestone

Comments

@Zhentar
Copy link

Zhentar commented Jul 21, 2018

BSR & BSF are functionally equivalent to LZCNT & TZCNT for non-zero values - except that instead of needing Haswell/Piledriver plus, the minimum requirement is 80386. Would be nice for things like Span.IndexOf where it's only applied to non-zero values.

BSWAP is an 80486 instruction that reverses the order of bytes. It's supposed to be good for endian-ness conversions, but I care because word on the street is that it's better than rotates for entropy diffusion in hash functions, leading to some of the trendy new fast hash functions (such as FarmHash and t1ha) using it.

category:proposal
theme:hardware-intrinsics
skill-level:intermediate
cost:medium

@voinokin
Copy link

voinokin commented Jul 21, 2018

Some extra information: binary encodings for LZCNT and TZCNT instructions correspond to one-byte prefix + corresponding BSR / BSF. According to Intel manuals encoded this way LZCNT/TZCNT are executed more or less the same as BSR/BSF by CPUs not yet supporting them except for the zero inputs (in such cases output value is set to input value). As to the on-CPU handling, all four instructions maintain data dependency on input register (perf).

@tannergooding
Copy link
Member

@Zhentar, could you open this as a formal API proposal against CoreFX? That will need to be done in order for it to go through API review.

@GrabYourPitchforks
Copy link
Member

FYI there's an existing PR for adding a BSWAP intrinsic (REV on ARM).
dotnet/coreclr#18398

@msftgits msftgits transferred this issue from dotnet/coreclr Jan 31, 2020
@msftgits msftgits added this to the Future milestone Jan 31, 2020
@saucecontrol
Copy link
Member

The other part of this was done in #34550

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI enhancement Product code improvement that does NOT require public API changes/additions
Projects
None yet
Development

No branches or pull requests

6 participants