@@ -935,9 +935,10 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
935935 }
936936
937937 macro_rules! require_simd {
938- ( $ty: expr, $variant: ident) => {
939- require!( $ty. is_simd( ) , InvalidMonomorphization :: $variant { span, name, ty: $ty } )
940- } ;
938+ ( $ty: expr, $variant: ident) => { {
939+ require!( $ty. is_simd( ) , InvalidMonomorphization :: $variant { span, name, ty: $ty } ) ;
940+ $ty. simd_size_and_type( bx. tcx( ) )
941+ } } ;
941942 }
942943
943944 let tcx = bx. tcx ( ) ;
@@ -946,9 +947,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
946947 let arg_tys = sig. inputs ( ) ;
947948
948949 if name == sym:: simd_select_bitmask {
949- require_simd ! ( arg_tys[ 1 ] , SimdArgument ) ;
950-
951- let ( len, _) = arg_tys[ 1 ] . simd_size_and_type ( bx. tcx ( ) ) ;
950+ let ( len, _) = require_simd ! ( arg_tys[ 1 ] , SimdArgument ) ;
952951
953952 let expected_int_bits = ( len. max ( 8 ) - 1 ) . next_power_of_two ( ) ;
954953 let expected_bytes = len / 8 + ( ( len % 8 > 0 ) as u64 ) ;
@@ -985,7 +984,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
985984 }
986985
987986 // every intrinsic below takes a SIMD vector as its first argument
988- require_simd ! ( arg_tys[ 0 ] , SimdInput ) ;
987+ let ( in_len , in_elem ) = require_simd ! ( arg_tys[ 0 ] , SimdInput ) ;
989988 let in_ty = arg_tys[ 0 ] ;
990989
991990 let comparison = match name {
@@ -998,11 +997,8 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
998997 _ => None ,
999998 } ;
1000999
1001- let ( in_len, in_elem) = arg_tys[ 0 ] . simd_size_and_type ( bx. tcx ( ) ) ;
10021000 if let Some ( cmp_op) = comparison {
1003- require_simd ! ( ret_ty, SimdReturn ) ;
1004-
1005- let ( out_len, out_ty) = ret_ty. simd_size_and_type ( bx. tcx ( ) ) ;
1001+ let ( out_len, out_ty) = require_simd ! ( ret_ty, SimdReturn ) ;
10061002
10071003 require ! (
10081004 in_len == out_len,
@@ -1038,8 +1034,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
10381034 . unwrap_branch ( ) ;
10391035 let n = idx. len ( ) as u64 ;
10401036
1041- require_simd ! ( ret_ty, SimdReturn ) ;
1042- let ( out_len, out_ty) = ret_ty. simd_size_and_type ( bx. tcx ( ) ) ;
1037+ let ( out_len, out_ty) = require_simd ! ( ret_ty, SimdReturn ) ;
10431038 require ! (
10441039 out_len == n,
10451040 InvalidMonomorphization :: ReturnLength { span, name, in_len: n, ret_ty, out_len }
@@ -1096,8 +1091,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
10961091 } ) ,
10971092 } ;
10981093
1099- require_simd ! ( ret_ty, SimdReturn ) ;
1100- let ( out_len, out_ty) = ret_ty. simd_size_and_type ( bx. tcx ( ) ) ;
1094+ let ( out_len, out_ty) = require_simd ! ( ret_ty, SimdReturn ) ;
11011095 require ! (
11021096 out_len == n,
11031097 InvalidMonomorphization :: ReturnLength { span, name, in_len: n, ret_ty, out_len }
@@ -1176,8 +1170,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
11761170 if name == sym:: simd_select {
11771171 let m_elem_ty = in_elem;
11781172 let m_len = in_len;
1179- require_simd ! ( arg_tys[ 1 ] , SimdArgument ) ;
1180- let ( v_len, _) = arg_tys[ 1 ] . simd_size_and_type ( bx. tcx ( ) ) ;
1173+ let ( v_len, _) = require_simd ! ( arg_tys[ 1 ] , SimdArgument ) ;
11811174 require ! (
11821175 m_len == v_len,
11831176 InvalidMonomorphization :: MismatchedLengths { span, name, m_len, v_len }
@@ -1395,14 +1388,16 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
13951388 // * M: any integer width is supported, will be truncated to i1
13961389
13971390 // All types must be simd vector types
1398- require_simd ! ( in_ty, SimdFirst ) ;
1399- require_simd ! ( arg_tys[ 1 ] , SimdSecond ) ;
1400- require_simd ! ( arg_tys[ 2 ] , SimdThird ) ;
1391+
1392+ // The second argument must be a simd vector with an element type that's a pointer
1393+ // to the element type of the first argument
1394+ let ( _, element_ty0) = require_simd ! ( in_ty, SimdFirst ) ;
1395+ let ( out_len, element_ty1) = require_simd ! ( arg_tys[ 1 ] , SimdSecond ) ;
1396+ // The element type of the third argument must be a signed integer type of any width:
1397+ let ( out_len2, element_ty2) = require_simd ! ( arg_tys[ 2 ] , SimdThird ) ;
14011398 require_simd ! ( ret_ty, SimdReturn ) ;
14021399
14031400 // Of the same length:
1404- let ( out_len, _) = arg_tys[ 1 ] . simd_size_and_type ( bx. tcx ( ) ) ;
1405- let ( out_len2, _) = arg_tys[ 2 ] . simd_size_and_type ( bx. tcx ( ) ) ;
14061401 require ! (
14071402 in_len == out_len,
14081403 InvalidMonomorphization :: SecondArgumentLength {
@@ -1432,11 +1427,6 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
14321427 InvalidMonomorphization :: ExpectedReturnType { span, name, in_ty, ret_ty }
14331428 ) ;
14341429
1435- // The second argument must be a simd vector with an element type that's a pointer
1436- // to the element type of the first argument
1437- let ( _, element_ty0) = arg_tys[ 0 ] . simd_size_and_type ( bx. tcx ( ) ) ;
1438- let ( _, element_ty1) = arg_tys[ 1 ] . simd_size_and_type ( bx. tcx ( ) ) ;
1439-
14401430 require ! (
14411431 matches!(
14421432 element_ty1. kind( ) ,
@@ -1453,8 +1443,6 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
14531443 }
14541444 ) ;
14551445
1456- // The element type of the third argument must be a signed integer type of any width:
1457- let ( _, element_ty2) = arg_tys[ 2 ] . simd_size_and_type ( bx. tcx ( ) ) ;
14581446 match element_ty2. kind ( ) {
14591447 ty:: Int ( _) => ( ) ,
14601448 _ => {
@@ -1512,13 +1500,13 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
15121500 // * M: any integer width is supported, will be truncated to i1
15131501
15141502 // All types must be simd vector types
1515- require_simd ! ( in_ty, SimdFirst ) ;
1516- require_simd ! ( arg_tys[ 1 ] , SimdSecond ) ;
1517- require_simd ! ( arg_tys[ 2 ] , SimdThird ) ;
1503+ // The second argument must be a simd vector with an element type that's a pointer
1504+ // to the element type of the first argument
1505+ let ( _, element_ty0) = require_simd ! ( in_ty, SimdFirst ) ;
1506+ let ( element_len1, element_ty1) = require_simd ! ( arg_tys[ 1 ] , SimdSecond ) ;
1507+ let ( element_len2, element_ty2) = require_simd ! ( arg_tys[ 2 ] , SimdThird ) ;
15181508
15191509 // Of the same length:
1520- let ( element_len1, _) = arg_tys[ 1 ] . simd_size_and_type ( bx. tcx ( ) ) ;
1521- let ( element_len2, _) = arg_tys[ 2 ] . simd_size_and_type ( bx. tcx ( ) ) ;
15221510 require ! (
15231511 in_len == element_len1,
15241512 InvalidMonomorphization :: SecondArgumentLength {
@@ -1542,12 +1530,6 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
15421530 }
15431531 ) ;
15441532
1545- // The second argument must be a simd vector with an element type that's a pointer
1546- // to the element type of the first argument
1547- let ( _, element_ty0) = arg_tys[ 0 ] . simd_size_and_type ( bx. tcx ( ) ) ;
1548- let ( _, element_ty1) = arg_tys[ 1 ] . simd_size_and_type ( bx. tcx ( ) ) ;
1549- let ( _, element_ty2) = arg_tys[ 2 ] . simd_size_and_type ( bx. tcx ( ) ) ;
1550-
15511533 require ! (
15521534 matches!(
15531535 element_ty1. kind( ) ,
@@ -1770,8 +1752,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
17701752 bitwise_red ! ( simd_reduce_any: vector_reduce_or, true ) ;
17711753
17721754 if name == sym:: simd_cast_ptr {
1773- require_simd ! ( ret_ty, SimdReturn ) ;
1774- let ( out_len, out_elem) = ret_ty. simd_size_and_type ( bx. tcx ( ) ) ;
1755+ let ( out_len, out_elem) = require_simd ! ( ret_ty, SimdReturn ) ;
17751756 require ! (
17761757 in_len == out_len,
17771758 InvalidMonomorphization :: ReturnLengthInputType {
@@ -1819,8 +1800,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
18191800 }
18201801
18211802 if name == sym:: simd_expose_addr {
1822- require_simd ! ( ret_ty, SimdReturn ) ;
1823- let ( out_len, out_elem) = ret_ty. simd_size_and_type ( bx. tcx ( ) ) ;
1803+ let ( out_len, out_elem) = require_simd ! ( ret_ty, SimdReturn ) ;
18241804 require ! (
18251805 in_len == out_len,
18261806 InvalidMonomorphization :: ReturnLengthInputType {
@@ -1848,8 +1828,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
18481828 }
18491829
18501830 if name == sym:: simd_from_exposed_addr {
1851- require_simd ! ( ret_ty, SimdReturn ) ;
1852- let ( out_len, out_elem) = ret_ty. simd_size_and_type ( bx. tcx ( ) ) ;
1831+ let ( out_len, out_elem) = require_simd ! ( ret_ty, SimdReturn ) ;
18531832 require ! (
18541833 in_len == out_len,
18551834 InvalidMonomorphization :: ReturnLengthInputType {
@@ -1877,8 +1856,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
18771856 }
18781857
18791858 if name == sym:: simd_cast || name == sym:: simd_as {
1880- require_simd ! ( ret_ty, SimdReturn ) ;
1881- let ( out_len, out_elem) = ret_ty. simd_size_and_type ( bx. tcx ( ) ) ;
1859+ let ( out_len, out_elem) = require_simd ! ( ret_ty, SimdReturn ) ;
18821860 require ! (
18831861 in_len == out_len,
18841862 InvalidMonomorphization :: ReturnLengthInputType {
0 commit comments