rust-lang / packed_simd

Portable Packed SIMD Vectors for Rust standard library
https://rust-lang.github.io/packed_simd/packed_simd_2/
Apache License 2.0
589 stars 74 forks source link

Shuffle macro internal compiler error #353

Closed ironhaven closed 1 year ago

ironhaven commented 1 year ago

Example code

use packed_simd::*;
fn main() {
    let v2 = i16x4::new(0,0,0,0);
    let _: i16x4 = shuffle!(v1, [0,0,0,0]);
}

Compiler error

error: internal compiler error: /rustc/4c8bb79d9f565115637cc6da739f8389e79f3a29\compiler\rustc_codegen_ssa\src\mir\constant.rs:70:22: Ty(
                                    Const { ty: [u32; 4], kind: IDX/#0 },
                                )
  --> C:\Users\user\.cargo\registry\src\index.crates.io-6f17d22bba15001f\packed_simd_2-0.3.8\src\codegen\llvm.rs:35:25
   |
35 |     simd_shuffle4(x, y, IDX)
   |                         ^^^

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/4c8bb79d9f565115637cc6da739f8389e79f3a29\compiler\rustc_errors\src\lib.rs:995:33
stack backtrace:
   0:     0x7ff92632810c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h1852d9055d20d0ab
   1:     0x7ff926361d2b - core::fmt::write::h07b3b269645691c2
   2:     0x7ff92631d401 - <std::io::IoSliceMut as core::fmt::Debug>::fmt::hf6d3ae126e468e25
   3:     0x7ff926327ebb - std::sys::common::alloc::realloc_fallback::hc1d692e2ae2e69c8   
   4:     0x7ff92632b72a - std::panicking::default_hook::h990430b890f8c6e3
   5:     0x7ff92632b37f - std::panicking::default_hook::h990430b890f8c6e3
   6:     0x7ff8ee05bf40 - rustc_driver_impl[fa4c965326efbab]::describe_lints
   7:     0x7ff92632c028 - std::panicking::rust_panic_with_hook::he907874d3f39b5d8        
   8:     0x7ff8ee210ea3 - <rustc_codegen_llvm[e14121f5b3b74158]::context::CodegenCx as rustc_codegen_ssa[bb2c78f268e0c57f]::traits::type_::TypeMembershipMethods>::set_kcfi_type_metadata
   9:     0x7ff8ee20e589 - <rustc_codegen_llvm[e14121f5b3b74158]::context::CodegenCx as rustc_codegen_ssa[bb2c78f268e0c57f]::traits::type_::TypeMembershipMethods>::set_kcfi_type_metadata
  10:     0x7ff8ee1cd9b9 - <rustc_codegen_llvm[e14121f5b3b74158]::llvm_::OperandBundleDef>::new
  11:     0x7ff8ee1eadd5 - <rustc_codegen_llvm[e14121f5b3b74158]::llvm_::archive_ro::Iter 
as core[df5b9ef56950d692]::ops::drop::Drop>::drop
  12:     0x7ff8ee1eab7d - <rustc_codegen_llvm[e14121f5b3b74158]::llvm_::archive_ro::Iter 
as core[df5b9ef56950d692]::ops::drop::Drop>::drop
  13:     0x7ff8ee1d0c98 - <rustc_codegen_llvm[e14121f5b3b74158]::llvm_::OperandBundleDef>::new
  14:     0x7ff8ee1d0ccd - <rustc_codegen_llvm[e14121f5b3b74158]::llvm_::OperandBundleDef>::new
  15:     0x7ff8ee1d044f - <rustc_codegen_llvm[e14121f5b3b74158]::llvm_::OperandBundleDef>::new
  16:     0x7ff8ee1cff76 - <rustc_codegen_llvm[e14121f5b3b74158]::llvm_::OperandBundleDef>::new
  17:     0x7ff8ea48dd67 - <rustc_codegen_llvm[e14121f5b3b74158]::context::CodegenCx as rustc_codegen_ssa[bb2c78f268e0c57f]::traits::type_::LayoutTypeMethods>::fn_ptr_backend_type 
  18:     0x7ff8ea47af2c - <rustc_codegen_llvm[e14121f5b3b74158]::context::CodegenCx as rustc_codegen_ssa[bb2c78f268e0c57f]::traits::type_::LayoutTypeMethods>::fn_ptr_backend_type 
  19:     0x7ff8ea485d1e - <rustc_codegen_llvm[e14121f5b3b74158]::context::CodegenCx as rustc_codegen_ssa[bb2c78f268e0c57f]::traits::type_::LayoutTypeMethods>::fn_ptr_backend_type 
  20:     0x7ff8ed16f19d - <rustc_target[cb7612b84a521cbc]::abi::TyAndLayout<rustc_middle[826994e1df3f4a30]::ty::Ty> as rustc_codegen_llvm[e14121f5b3b74158]::type_of::LayoutLlvmExt>::scalar_copy_llvm_type
  21:     0x7ff8ed13e71c - <rustc_codegen_llvm[e14121f5b3b74158]::base::ValueIter as core[df5b9ef56950d692]::iter::traits::iterator::Iterator>::next
  22:     0x7ff8ea42b818 - rustc_codegen_llvm[e14121f5b3b74158]::llvm_util::target_features
  23:     0x7ff8ea4625b3 - <rustc_codegen_llvm[e14121f5b3b74158]::builder::Builder as rustc_codegen_ssa[bb2c78f268e0c57f]::traits::builder::BuilderMethods>::unchecked_umul
  24:     0x7ff8ea44edb7 - <rustc_codegen_llvm[e14121f5b3b74158]::llvm_::archive_ro::Child as core[df5b9ef56950d692]::ops::drop::Drop>::drop
  25:     0x7ff8ea41b686 - <rustc_codegen_llvm[e14121f5b3b74158]::LlvmCodegenBackend as rustc_codegen_ssa[bb2c78f268e0c57f]::traits::backend::CodegenBackend>::codegen_crate        
  26:     0x7ff8ea3f5849 - rustc_interface[db5b726bda526d67]::callbacks::setup_callbacks  
  27:     0x7ff8ea3e4f0a - rustc_interface[db5b726bda526d67]::passes::start_codegen       
  28:     0x7ff8ea3d2f08 - <tracing_subscriber[4114f88fae6e74d4]::filter::directive::StaticDirective>::new
  29:     0x7ff8ea3db705 - <rustc_interface[db5b726bda526d67]::queries::Queries>::ongoing_codegen
  30:     0x7ff8ea3a9a97 - rustc_driver_impl[fa4c965326efbab]::args::arg_expand_all       
  31:     0x7ff8ea3a607a - rustc_driver_impl[fa4c965326efbab]::args::arg_expand_all       
  32:     0x7ff8ea3be21d - rustc_driver_impl[fa4c965326efbab]::args::arg_expand_all       
  33:     0x7ff8ea3bee59 - rustc_driver_impl[fa4c965326efbab]::args::arg_expand_all
  34:     0x7ff8ea3bd646 - rustc_driver_impl[fa4c965326efbab]::args::arg_expand_all       
  35:     0x7ff92633f61c - std::sys::windows::thread::Thread::new::he46233e2afb83d55      
  36:     0x7ff9a87a7614 - BaseThreadInitThunk
  37:     0x7ff9a88e26f1 - RtlUserThreadStart

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.73.0-nightly (4c8bb79d9 2023-07-15) running on x86_64-pc-windows-msvc       

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED] -C target-feature=+avx,+avx2

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

query stack during panic:
end of query stack

Code was run on Windows 10 with a AMD Ryzen 8 5900X

workingjubilee commented 1 year ago

A mitigation is already active on nightly, and this will be fixed outright in-library in the 0.3.9 release.

workingjubilee commented 1 year ago

0.3.9 is out, it will work with new compilers.