Skip to content

error: failed to parse bitcode for LTO module: Invalid cast #110707

Closed
@connerebbinghaus

Description

@connerebbinghaus

Compiling the following in release on the recent nightlies causes a crash. Note that compiling in debug succeeds.

Code

#![feature(portable_simd)]
use std::simd::*;
use std::arch::x86_64::*;

#[target_feature(enable = "sse4.1")]
pub unsafe fn fast_round_sse(i: f32x8) -> f32x8 {
    let a = i.to_array();
    let [low, high]: [[f32; 4]; 2] =
        unsafe { std::mem::transmute::<[f32; 8], [[f32; 4]; 2]>(a) };
        
    let low = f32x4::from(_mm_round_ps::<{_MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC}>(f32x4::from_array(low).into()));
    let high = f32x4::from(_mm_round_ps::<{_MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC}>(f32x4::from_array(high).into()));

    let a: [f32; 8] =
        unsafe { std::mem::transmute::<[[f32; 4]; 2], [f32; 8]>([low.to_array(), high.to_array()]) };
    f32x8::from_array(a)
}

//#[target_feature(enable = "sse4.1")]
//pub unsafe fn round_many(b: &mut [f32x8]) {
//    for a in b {
//        *a = fast_round_sse(*a);
//    }
//}

Meta

rustc --version --verbose:

rustc 1.71.0-nightly (fec9adcdb 2023-04-21)
binary: rustc
commit-hash: fec9adcdbc21469ef105162cc8cabf81c72d06be
commit-date: 2023-04-21
host: x86_64-unknown-linux-gnu
release: 1.71.0-nightly
LLVM version: 16.0.2

Error output

error: failed to parse bitcode for LTO module: Invalid cast (Producer: 'LLVM16.0.2-rust-1.71.0-nightly' Reader: 'LLVM 16.0.2-rust-1.71.0-nightly')

error: could not compile `ice_repro` (lib) due to previous error

If the round_many function is uncommented, rustc instead crashes with an illegal instruction

error: could not compile `ice_repro` (lib)

Caused by:
  process didn't exit successfully: `rustc --crate-name ice_repro --edition=2021 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=236 --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C embed-bitcode=no -C metadata=720812225537f937 -C extra-filename=-720812225537f937 --out-dir /home/conner/ice_repro/target/release/deps -L dependency=/home/conner/ice_repro/target/release/deps` (signal: 4, SIGILL: illegal instruction)

Bisect

searched nightlies: from nightly-2023-04-17 to nightly-2023-04-23
regressed nightly: nightly-2023-04-18
searched commit range: d0f204e...7908a1d
regressed commit: 5546cb6

bisected with cargo-bisect-rustc v0.6.6

Host triple: x86_64-unknown-linux-gnu
Reproduce with:

cargo bisect-rustc -- build --release 

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-SIMDArea: SIMD (Single Instruction Multiple Data)C-bugCategory: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️PG-portable-simdProject group: Portable SIMD (https://github.com/rust-lang/project-portable-simd)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