diff options
| author | bors <bors@rust-lang.org> | 2021-09-19 11:03:09 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-09-19 11:03:09 +0000 |
| commit | 08a0307b32ec5af243880056d7cf524f2eff8d69 (patch) | |
| tree | a0d72c00cf6c7918025c7b44f2654d19c9ce8cb7 /compiler/rustc_codegen_llvm/src | |
| parent | 7a3d1a5f3dfeaf5177885fedd7db8ecc70670dc1 (diff) | |
| parent | 4877ad3d12a89efb08d850628d05dcd7a1416490 (diff) | |
| download | rust-08a0307b32ec5af243880056d7cf524f2eff8d69.tar.gz rust-08a0307b32ec5af243880056d7cf524f2eff8d69.zip | |
Auto merge of #89089 - JohnTitor:rollup-6s6mccx, r=JohnTitor
Rollup of 10 pull requests Successful merges: - #87960 (Suggest replacing an inexisting field for an unmentioned field) - #88855 (Allow simd_shuffle to accept vectors of any length) - #88966 (Check for shadowing issues involving block labels) - #88996 (Fix linting when trailing macro expands to a trailing semi) - #89017 (fix potential race in AtomicU64 time monotonizer) - #89021 (Add a separate error for `dyn Trait` in `const fn`) - #89051 (Add intra-doc links and small changes to `std::os` to be more consistent) - #89053 (refactor: VecDeques IntoIter fields to private) - #89055 (Suggest better place to add call parentheses for method expressions wrapped in parentheses) - #89081 (Fix a typo) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/intrinsic.rs | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/compiler/rustc_codegen_llvm/src/intrinsic.rs b/compiler/rustc_codegen_llvm/src/intrinsic.rs index 1060f911a9e..b309a124e80 100644 --- a/compiler/rustc_codegen_llvm/src/intrinsic.rs +++ b/compiler/rustc_codegen_llvm/src/intrinsic.rs @@ -918,12 +918,29 @@ fn generic_simd_intrinsic( } if let Some(stripped) = name_str.strip_prefix("simd_shuffle") { - let n: u64 = stripped.parse().unwrap_or_else(|_| { - span_bug!(span, "bad `simd_shuffle` instruction only caught in codegen?") - }); + // If this intrinsic is the older "simd_shuffleN" form, simply parse the integer. + // If there is no suffix, use the index array length. + let n: u64 = if stripped.is_empty() { + // Make sure this is actually an array, since typeck only checks the length-suffixed + // version of this intrinsic. + match args[2].layout.ty.kind() { + ty::Array(ty, len) if matches!(ty.kind(), ty::Uint(ty::UintTy::U32)) => { + len.try_eval_usize(bx.cx.tcx, ty::ParamEnv::reveal_all()).unwrap_or_else(|| { + span_bug!(span, "could not evaluate shuffle index array length") + }) + } + _ => return_error!( + "simd_shuffle index must be an array of `u32`, got `{}`", + args[2].layout.ty + ), + } + } else { + stripped.parse().unwrap_or_else(|_| { + span_bug!(span, "bad `simd_shuffle` instruction only caught in codegen?") + }) + }; require_simd!(ret_ty, "return"); - let (out_len, out_ty) = ret_ty.simd_size_and_type(bx.tcx()); require!( out_len == n, |
