Skip to content

Compiler bug in simd intrinsics for usize types #89193

Closed
@dyv

Description

@dyv

As far as I can tell this bug only exists when performing a simd gather instruction on a slice of usize. If the slice is instead typed as u64 or u32 this code succeeds.

Code

#![feature(portable_simd)]
use core_simd::Simd;

fn main() {
    let indexes: [usize; 4] = [0, 1, 2, 3];
    let simd_indexes: Simd<usize, 4> = Simd::from_array(indexes);
    let slice: [usize; 4] = [10, 11, 12, 13];
    let result = Simd::gather_or_default(&slice, simd_indexes);
    assert_eq!(result, Simd::from_array([10, 11, 12, 13]));
}

Cargo.toml

[package]
name = "simd-repro"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
core_simd = { git = "https://github.com/rust-lang/portable-simd", rev = "c2f59483f96cf1ab1e92cf10e0f9094432a8374c" }

Meta

rustc --version --verbose:

rustc 1.57.0-nightly (ac2d9fc50 2021-09-21)
binary: rustc
commit-hash: ac2d9fc509e36d1b32513744adf58c34bcc4f43c
commit-date: 2021-09-21
host: x86_64-unknown-linux-gnu
release: 1.57.0-nightly
LLVM version: 13.0.0

Error output

dylan@lion:~/src/simd-repro$ RUST_BACKTRACE=1 cargo run
   Compiling simd-repro v0.1.0 (/home/dylan/src/simd-repro)
thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', compiler/rustc_codegen_llvm/src/intrinsic.rs:1194:76
stack backtrace:
   0: rust_begin_unwind
             at /rustc/ac2d9fc509e36d1b32513744adf58c34bcc4f43c/library/std/src/panicking.rs:517:5
   1: core::panicking::panic_fmt
             at /rustc/ac2d9fc509e36d1b32513744adf58c34bcc4f43c/library/core/src/panicking.rs:103:14
   2: core::panicking::panic
             at /rustc/ac2d9fc509e36d1b32513744adf58c34bcc4f43c/library/core/src/panicking.rs:50:5
   3: rustc_codegen_llvm::intrinsic::generic_simd_intrinsic::llvm_vector_str
   4: rustc_codegen_llvm::intrinsic::generic_simd_intrinsic
   5: rustc_codegen_llvm::intrinsic::<impl rustc_codegen_ssa::traits::intrinsic::IntrinsicCallMethods for rustc_codegen_llvm::builder::Builder>::codegen_intrinsic_call
   6: rustc_codegen_ssa::mir::intrinsic::<impl rustc_codegen_ssa::mir::FunctionCx<Bx>>::codegen_intrinsic_call
   7: rustc_codegen_ssa::mir::block::<impl rustc_codegen_ssa::mir::FunctionCx<Bx>>::codegen_terminator
   8: rustc_codegen_ssa::mir::codegen_mir
   9: rustc_codegen_ssa::base::codegen_instance
  10: rustc_codegen_llvm::base::compile_codegen_unit::module_codegen
  11: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task
  12: rustc_codegen_llvm::base::compile_codegen_unit
  13: rustc_codegen_ssa::base::codegen_crate
  14: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
  15: rustc_interface::queries::Queries::ongoing_codegen
  16: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  17: rustc_span::with_source_map
  18: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.57.0-nightly (ac2d9fc50 2021-09-21) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type bin

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
error: could not compile `simd-repro`

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️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