@@ -935,9 +935,10 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
935
935
}
936
936
937
937
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
+ } } ;
941
942
}
942
943
943
944
let tcx = bx. tcx ( ) ;
@@ -946,9 +947,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
946
947
let arg_tys = sig. inputs ( ) ;
947
948
948
949
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 ) ;
952
951
953
952
let expected_int_bits = ( len. max ( 8 ) - 1 ) . next_power_of_two ( ) ;
954
953
let expected_bytes = len / 8 + ( ( len % 8 > 0 ) as u64 ) ;
@@ -985,7 +984,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
985
984
}
986
985
987
986
// 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 ) ;
989
988
let in_ty = arg_tys[ 0 ] ;
990
989
991
990
let comparison = match name {
@@ -998,11 +997,8 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
998
997
_ => None ,
999
998
} ;
1000
999
1001
- let ( in_len, in_elem) = arg_tys[ 0 ] . simd_size_and_type ( bx. tcx ( ) ) ;
1002
1000
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 ) ;
1006
1002
1007
1003
require ! (
1008
1004
in_len == out_len,
@@ -1038,8 +1034,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
1038
1034
. unwrap_branch ( ) ;
1039
1035
let n = idx. len ( ) as u64 ;
1040
1036
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 ) ;
1043
1038
require ! (
1044
1039
out_len == n,
1045
1040
InvalidMonomorphization :: ReturnLength { span, name, in_len: n, ret_ty, out_len }
@@ -1096,8 +1091,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
1096
1091
} ) ,
1097
1092
} ;
1098
1093
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 ) ;
1101
1095
require ! (
1102
1096
out_len == n,
1103
1097
InvalidMonomorphization :: ReturnLength { span, name, in_len: n, ret_ty, out_len }
@@ -1176,8 +1170,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
1176
1170
if name == sym:: simd_select {
1177
1171
let m_elem_ty = in_elem;
1178
1172
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 ) ;
1181
1174
require ! (
1182
1175
m_len == v_len,
1183
1176
InvalidMonomorphization :: MismatchedLengths { span, name, m_len, v_len }
@@ -1395,14 +1388,16 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
1395
1388
// * M: any integer width is supported, will be truncated to i1
1396
1389
1397
1390
// 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 ) ;
1401
1398
require_simd ! ( ret_ty, SimdReturn ) ;
1402
1399
1403
1400
// 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 ( ) ) ;
1406
1401
require ! (
1407
1402
in_len == out_len,
1408
1403
InvalidMonomorphization :: SecondArgumentLength {
@@ -1432,11 +1427,6 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
1432
1427
InvalidMonomorphization :: ExpectedReturnType { span, name, in_ty, ret_ty }
1433
1428
) ;
1434
1429
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
-
1440
1430
require ! (
1441
1431
matches!(
1442
1432
element_ty1. kind( ) ,
@@ -1453,8 +1443,6 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
1453
1443
}
1454
1444
) ;
1455
1445
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 ( ) ) ;
1458
1446
match element_ty2. kind ( ) {
1459
1447
ty:: Int ( _) => ( ) ,
1460
1448
_ => {
@@ -1512,13 +1500,13 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
1512
1500
// * M: any integer width is supported, will be truncated to i1
1513
1501
1514
1502
// 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 ) ;
1518
1508
1519
1509
// 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 ( ) ) ;
1522
1510
require ! (
1523
1511
in_len == element_len1,
1524
1512
InvalidMonomorphization :: SecondArgumentLength {
@@ -1542,12 +1530,6 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
1542
1530
}
1543
1531
) ;
1544
1532
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
-
1551
1533
require ! (
1552
1534
matches!(
1553
1535
element_ty1. kind( ) ,
@@ -1770,8 +1752,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
1770
1752
bitwise_red ! ( simd_reduce_any: vector_reduce_or, true ) ;
1771
1753
1772
1754
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 ) ;
1775
1756
require ! (
1776
1757
in_len == out_len,
1777
1758
InvalidMonomorphization :: ReturnLengthInputType {
@@ -1819,8 +1800,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
1819
1800
}
1820
1801
1821
1802
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 ) ;
1824
1804
require ! (
1825
1805
in_len == out_len,
1826
1806
InvalidMonomorphization :: ReturnLengthInputType {
@@ -1848,8 +1828,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
1848
1828
}
1849
1829
1850
1830
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 ) ;
1853
1832
require ! (
1854
1833
in_len == out_len,
1855
1834
InvalidMonomorphization :: ReturnLengthInputType {
@@ -1877,8 +1856,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
1877
1856
}
1878
1857
1879
1858
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 ) ;
1882
1860
require ! (
1883
1861
in_len == out_len,
1884
1862
InvalidMonomorphization :: ReturnLengthInputType {
0 commit comments