rust-lang / stdarch

Rust's standard library vendor-specific APIs and run-time feature detection
https://doc.rust-lang.org/stable/core/arch/
Apache License 2.0
598 stars 255 forks source link

use `simd_saturating_{add, sub}` on neon #1575

Open folkertdev opened 1 month ago

folkertdev commented 1 month ago

The idea behind this is that e.g. miri and cranelift don't know all of the llvm intrinsics (and adding them is possible but a lot of extra work). Using the generic simd function means logic only needs to be implemented once for all targets.

The simd_saturating_* functions generate the same instructions for the saturating add/sub operations https://godbolt.org/z/zc35doTc6

rustbot commented 1 month ago

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Amanieu (or someone else) some time within the next two weeks.

folkertdev commented 1 month ago

I don't think this idea works because of this LLVM issue I opened https://github.com/llvm/llvm-project/issues/94463. So unless we can get that fixed (or somehow accept much worse codegen) this PR does not work

Amanieu commented 1 month ago

OK let's defer this for now until the LLVM issue is sorted.