Skip to content

aarch64: use intrinsics::simd for horizontal add and abs #1872

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

folkertdev
Copy link
Contributor

No description provided.

@rustbot
Copy link
Collaborator

rustbot commented Jul 12, 2025

r? @Amanieu

rustbot has assigned @Amanieu.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@folkertdev folkertdev changed the title Aarch64 horizontal add aarch64: use intrinsics::simd for horizontal add and abs Jul 12, 2025
Comment on lines -301 to +308
unsafe extern "unadjusted" {
#[cfg_attr(
any(target_arch = "aarch64", target_arch = "arm64ec"),
link_name = "llvm.aarch64.neon.abs.v1i64"
)]
fn _vabs_s64(a: int64x1_t) -> int64x1_t;
unsafe {
let neg: int64x1_t = simd_neg(a);
let mask: int64x1_t = simd_ge(a, neg);
simd_select(mask, a, neg)
}
unsafe { _vabs_s64(a) }
}
#[doc = "Absolute Value (wrapping)."]
#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vabsd_s64)"]
#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vabsq_s64)"]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the diff here is wonky because the order of the definitions changed.

Comment on lines +13037 to +13043
# FIXME(llvm): this should be `i64::wrapping_abs` but it optimizes differently.
# See https://github.com/llvm/llvm-project/issues/148388.
- LLVMLink:
name: "vabsd_s64"
links:
- link: "llvm.aarch64.neon.abs.i64"
arch: aarch64,arm64ec
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc llvm/llvm-project#148388

Just kept this as-is for now, but from what I can tell i64::wrapping_abs would be equivalent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants