Skip to content

Consider limiting #[rustc_args_required_const(...)] to intrinsics. #70271

Closed

Description

I've just been made aware that functions like this exist: https://github.com/rust-lang/stdarch/blob/abe96ca3b87fcca6aa1dfcefd40d8c8d92d2e673/crates/core_arch/src/x86_64/avx2.rs#L28-L34

#[rustc_args_required_const(1)]
// This intrinsic has no corresponding instruction.
#[stable(feature = "simd_x86", since = "1.27.0")]
pub unsafe fn _mm256_extract_epi64(a: __m256i, imm8: i32) -> i64 {
    let imm8 = (imm8 & 3) as u32;
    simd_extract(a.as_i64x4(), imm8)
}

I was under the impression that #[rustc_args_required_const(...)] would be used primarily for intrinsics (including the behind-rustc's-back imported LLVM intrinsics), and maybe unstable implementation details.

At least right now I am uncomfortable letting #[rustc_args_required_const(...)] proliferate any further, and would much prefer any stabilized library-defined functions that rely on the attribute, to become true intrinsics.

Sadly, there are a few of them, so this won't be trivial.

cc @rust-lang/compiler

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-SIMDArea: SIMD (Single Instruction Multiple Data)Area: SIMD (Single Instruction Multiple Data)A-const-evalArea: Constant evaluation (MIR interpretation)Area: Constant evaluation (MIR interpretation)C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language team, which will review and decide on the PR/issue.Relevant to the language team, which will review and decide on the PR/issue.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API 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