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

Support memchr on arm64 too #4191

Open
bjorn3 opened this issue Feb 13, 2025 · 5 comments · May be fixed by #4193
Open

Support memchr on arm64 too #4191

bjorn3 opened this issue Feb 13, 2025 · 5 comments · May be fixed by #4193
Labels
A-intrinsics Area: Affects out implementation of Rust intrinsics A-shims Area: This affects the external function shims C-enhancement Category: a PR with an enhancement or an issue tracking an accepted enhancement

Comments

@bjorn3
Copy link
Member

bjorn3 commented Feb 13, 2025

Miri has implemented all vendor intrinsics needed by the memchr crate on x86. It still misses them for arm64 however.

@bjorn3 bjorn3 added A-shims Area: This affects the external function shims C-enhancement Category: a PR with an enhancement or an issue tracking an accepted enhancement labels Feb 13, 2025
@RalfJung RalfJung added the A-intrinsics Area: Affects out implementation of Rust intrinsics label Feb 13, 2025
@RalfJung
Copy link
Member

Yeah we had a heroic contributor implement a lot of x86 intrinsics.

Do you have a list of intrinsics we'd need for this? Is there some place the semantics of these intrinsics are documented?

@bjorn3
Copy link
Member Author

bjorn3 commented Feb 13, 2025

I believe https://github.com/BurntSushi/memchr/blob/746182171d2e88600652de3e6768cd8aef77e585/src/vector.rs#L292-L460 has all uses of arm64 vendor intrinsics. So

  • vdupq_n_u8
  • vld1q_u8
  • vreinterpretq_u16_u8
  • vshrn_n_u16
  • vreinterpret_u64_u8
  • vget_lane_u64
  • vceqq_u8
  • vandq_u8
  • vorrq_u8
  • vreinterpretq_u64_u8
  • vgetq_lane_u64
  • vpmaxq_u8

Several of these are implemented using the same intrinsics as portable-simd and as such likely already supported. For the remaining ones the core::arch doc pages link to the arm documentation which contains their behavior both as english text and in the form of a function implemented in a custom dsl.

@bjorn3
Copy link
Member Author

bjorn3 commented Feb 14, 2025

Only vpmaxq_u8 needed a miri implementation. There rest seems to use portable simd intrinsics internally.

@RalfJung
Copy link
Member

the core::arch doc pages link to the arm documentation

I can't find such a link at https://doc.rust-lang.org/nightly/core/arch/aarch64/fn.vpmaxq_u8.html ?

@bjorn3
Copy link
Member Author

bjorn3 commented Feb 14, 2025

I guess some are missing the link. In any case I've implemented it locally, but I'm getting two weird test failures.

@bjorn3 bjorn3 linked a pull request Feb 14, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-intrinsics Area: Affects out implementation of Rust intrinsics A-shims Area: This affects the external function shims C-enhancement Category: a PR with an enhancement or an issue tracking an accepted enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants