Skip to content

"rustc-LLVM ERROR" when using _mm_cvttps_epi32 on x86_64-unknown-none #133707

Open
@eduardosm

Description

I tried this code:

#![no_std]

use core::arch::x86_64::*;

pub unsafe fn func() -> __m128i {
    _mm_cvttps_epi32(_mm_setzero_ps())
}

It builds fine on x86_64-unknown-linux-gnu, but fails on x86_64-unknown-none:

rustc-LLVM ERROR: Do not know how to split the result of this operator!

Adding #[target_feature(enable = "sse2")] or using -C target-feature=+sse2 does not prevent the error.

Meta

rustc --version --verbose:

rustc 1.85.0-nightly (7442931d4 2024-11-30)
binary: rustc
commit-hash: 7442931d49b199ad0a1cc0f8ca54e327b5139b66
commit-date: 2024-11-30
host: x86_64-unknown-linux-gnu
release: 1.85.0-nightly
LLVM version: 19.1.4

Activity

added
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Dec 1, 2024
hanna-kruppe

hanna-kruppe commented on Dec 1, 2024

@hanna-kruppe
Contributor

It seems that target doesn't enable the SSE2 target feature, which is required for this intrinsic, by default. According to the target documentation this is intentional:

By default, Rust code generated for this target does not use any vector or floating-point registers (e.g. SSE, AVX). This allows the generated code to run in environments, such as kernels, which may need to avoid the use of such registers or which may have special considerations about the use of such registers (e.g. saving and restoring them to avoid breaking userspace code using the same registers). You can change code generation to use additional CPU features via the -C target-feature= codegen options to rustc, or via the #[target_feature] mechanism within Rust code.

eduardosm

eduardosm commented on Dec 1, 2024

@eduardosm
ContributorAuthor

Still fails after adding #[target_feature(enable = "sse2")] to func or passing -C target-feature=+sse2.

added
O-x86_64Target: x86-64 processors (like x86_64-*)
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
A-target-featureArea: Enabling/disabling target features like AVX, Neon, etc.
and removed
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-target-featureArea: Enabling/disabling target features like AVX, Neon, etc.C-bugCategory: This is a bug.O-x86_64Target: x86-64 processors (like x86_64-*)T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      "rustc-LLVM ERROR" when using `_mm_cvttps_epi32` on x86_64-unknown-none · Issue #133707 · rust-lang/rust