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

Intrinsics not inlined despite cfg. #83137

Closed
human-0 opened this issue Mar 15, 2021 · 2 comments
Closed

Intrinsics not inlined despite cfg. #83137

human-0 opened this issue Mar 15, 2021 · 2 comments
Labels
regression-from-stable-to-nightly Performance or correctness regression from stable to nightly.

Comments

@human-0
Copy link

human-0 commented Mar 15, 2021

Code

I tried this code:

#[cfg(
    all(
        any(target_arch = "x86", target_arch = "x86_64"),
        target_feature = "sse2"
    )
)]
fn some_fn(...) -> Something {
    #[cfg(target_arch = "x86")]
    use std::arch::x86::*;
    #[cfg(target_arch = "x86_64")]
    use std::arch::x86_64::*;
    unsafe {
        some_sse2_code
    }
}

I expected to see this happen: The SSE2 intrinsics would be inlined. The target_arch was native (skylake).

Instead, this happened: The intrinsics were not inlined, and required a function call each time. Some of the functions were just two moves and the operation, others had _ZN4core9core_arch3x868m128iExt8 in them.
e.g. _mm_or_si128 was just

vmovaps	xmm0, xmmword ptr [r8]
vxorps	xmm0, xmm0, xmmword ptr [rdx]
vmovaps	xmmword ptr [rcx], xmm0
ret

but _mm_sub_epi64 was more complex. Both intrinsics should have been inlined.

Version it worked on

It most recently worked on: rustc 1.50

Version with regression

rustc --version --verbose:

rustc 1.52.0-nightly (d6eaea1c8 2021-03-14)
binary: rustc
commit-hash: d6eaea1c8860adb5302d2fbaad409e36585ab217
commit-date: 2021-03-14
host: x86_64-pc-windows-msvc
release: 1.52.0-nightly
LLVM version: 12.0.0
@rustbot rustbot added regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Mar 15, 2021
@nikic
Copy link
Contributor

nikic commented Mar 15, 2021

Probably a duplicate of #83027.

@human-0
Copy link
Author

human-0 commented Mar 15, 2021

Indeed it is.

@human-0 human-0 closed this as completed Mar 15, 2021
@JohnTitor JohnTitor removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Mar 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
regression-from-stable-to-nightly Performance or correctness regression from stable to nightly.
Projects
None yet
Development

No branches or pull requests

4 participants