@@ -67,7 +67,34 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
67
67
_ if intrinsic. as_str( ) . starts_with( "simd_shuffle" ) , ( c x, c y, o idx) {
68
68
validate_simd_type!( fx, intrinsic, span, x. layout( ) . ty) ;
69
69
70
- let n: u16 = intrinsic. as_str( ) [ "simd_shuffle" . len( ) ..] . parse( ) . unwrap( ) ;
70
+ // If this intrinsic is the older "simd_shuffleN" form, simply parse the integer.
71
+ // If there is no suffix, use the index array length.
72
+ let n: u16 = if intrinsic == sym:: simd_shuffle {
73
+ // Make sure this is actually an array, since typeck only checks the length-suffixed
74
+ // version of this intrinsic.
75
+ let idx_ty = fx. monomorphize( idx. ty( fx. mir, fx. tcx) ) ;
76
+ match idx_ty. kind( ) {
77
+ ty:: Array ( ty, len) if matches!( ty. kind( ) , ty:: Uint ( ty:: UintTy :: U32 ) ) => {
78
+ len. try_eval_usize( fx. tcx, ty:: ParamEnv :: reveal_all( ) ) . unwrap_or_else( || {
79
+ span_bug!( span, "could not evaluate shuffle index array length" )
80
+ } ) . try_into( ) . unwrap( )
81
+ }
82
+ _ => {
83
+ fx. tcx. sess. span_err(
84
+ span,
85
+ & format!(
86
+ "simd_shuffle index must be an array of `u32`, got `{}`" ,
87
+ idx_ty,
88
+ ) ,
89
+ ) ;
90
+ // Prevent verifier error
91
+ crate :: trap:: trap_unreachable( fx, "compilation should not have succeeded" ) ;
92
+ return ;
93
+ }
94
+ }
95
+ } else {
96
+ intrinsic. as_str( ) [ "simd_shuffle" . len( ) ..] . parse( ) . unwrap( )
97
+ } ;
71
98
72
99
assert_eq!( x. layout( ) , y. layout( ) ) ;
73
100
let layout = x. layout( ) ;
0 commit comments