From cebdfe40adcbbfa8883ac1c2ea2933456b34cf90 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Sun, 15 Sep 2024 17:07:29 +0000 Subject: [PATCH] Slightly simplify the simd_shuffle impl --- src/intrinsics/simd.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/intrinsics/simd.rs b/src/intrinsics/simd.rs index a5621aec244..5972d9c6f6b 100644 --- a/src/intrinsics/simd.rs +++ b/src/intrinsics/simd.rs @@ -182,11 +182,9 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( // Make sure this is actually a SIMD vector. let idx_ty = fx.monomorphize(idx.node.ty(fx.mir, fx.tcx)); - let n: u16 = if idx_ty.is_simd() - && matches!(idx_ty.simd_size_and_type(fx.tcx).1.kind(), ty::Uint(ty::UintTy::U32)) + if !idx_ty.is_simd() + || !matches!(idx_ty.simd_size_and_type(fx.tcx).1.kind(), ty::Uint(ty::UintTy::U32)) { - idx_ty.simd_size_and_type(fx.tcx).0.try_into().unwrap() - } else { fx.tcx.dcx().span_err( span, format!("simd_shuffle index must be a SIMD vector of `u32`, got `{}`", idx_ty), @@ -195,6 +193,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( fx.bcx.ins().trap(TrapCode::UnreachableCodeReached); return; }; + let n: u16 = idx_ty.simd_size_and_type(fx.tcx).0.try_into().unwrap(); assert_eq!(x.layout(), y.layout()); let layout = x.layout();