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

Builtin popcount, clz, ctz #92

Closed
konsumlamm opened this issue Jan 16, 2025 · 1 comment · Fixed by #94
Closed

Builtin popcount, clz, ctz #92

konsumlamm opened this issue Jan 16, 2025 · 1 comment · Fixed by #94
Labels
enhancement New feature or request

Comments

@konsumlamm
Copy link
Contributor

I'm interested in adding builtins for popcount, count leading zeros (clz) and count trailing zeros (ctz), since these have specialized CPU instructions on many platforms. They would be used in the Bits/FiniteBits instances for Int/Word etc. Looking at the runtime, it seems builtins are either implemented as primops or as FFI functions. Which would be preferable here?

@augustss
Copy link
Owner

I think I'd do it as primops.

There will have to be C versions of these functions for the platforms that don't have instructions.
You can see how FFS is done.

@augustss augustss added the enhancement New feature or request label Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants