@@ -1315,11 +1315,8 @@ pub unsafe fn vtbx4_p8(a: poly8x8_t, b: poly8x8x4_t, c: uint8x8_t) -> poly8x8_t
1315
1315
// `mov` seems to be an acceptable intrinsic to compile to
1316
1316
// #[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(vmov, imm5 = 1))]
1317
1317
pub unsafe fn vgetq_lane_u64 ( v : uint64x2_t , imm5 : i32 ) -> u64 {
1318
- if ( imm5) < 0 || ( imm5) > 1 {
1319
- unreachable_unchecked ( )
1320
- }
1321
- let imm5 = ( imm5 & 0b1 ) as u32 ;
1322
- simd_extract ( v, imm5)
1318
+ assert ! ( imm5 >= 0 && imm5 <= 1 ) ;
1319
+ simd_extract ( v, imm5 as u32 )
1323
1320
}
1324
1321
1325
1322
/// Move vector element to general-purpose register
@@ -1332,9 +1329,7 @@ pub unsafe fn vgetq_lane_u64(v: uint64x2_t, imm5: i32) -> u64 {
1332
1329
// FIXME: no 32bit this seems to be turned into two vmov.32 instructions
1333
1330
// validate correctness
1334
1331
pub unsafe fn vget_lane_u64 ( v : uint64x1_t , imm5 : i32 ) -> u64 {
1335
- if imm5 != 0 {
1336
- unreachable_unchecked ( )
1337
- }
1332
+ assert ! ( imm5 == 0 ) ;
1338
1333
simd_extract ( v, 0 )
1339
1334
}
1340
1335
@@ -1346,11 +1341,8 @@ pub unsafe fn vget_lane_u64(v: uint64x1_t, imm5: i32) -> u64 {
1346
1341
#[ cfg_attr( all( test, target_arch = "arm" ) , assert_instr( "vmov.u16" , imm5 = 2 ) ) ]
1347
1342
#[ cfg_attr( all( test, target_arch = "aarch64" ) , assert_instr( umov, imm5 = 2 ) ) ]
1348
1343
pub unsafe fn vgetq_lane_u16 ( v : uint16x8_t , imm5 : i32 ) -> u16 {
1349
- if ( imm5) < 0 || ( imm5) > 7 {
1350
- unreachable_unchecked ( )
1351
- }
1352
- let imm5 = ( imm5 & 0b111 ) as u32 ;
1353
- simd_extract ( v, imm5)
1344
+ assert ! ( imm5 >= 0 && imm5 <= 7 ) ;
1345
+ simd_extract ( v, imm5 as u32 )
1354
1346
}
1355
1347
1356
1348
/// Move vector element to general-purpose register
@@ -1361,11 +1353,20 @@ pub unsafe fn vgetq_lane_u16(v: uint16x8_t, imm5: i32) -> u16 {
1361
1353
#[ cfg_attr( all( test, target_arch = "arm" ) , assert_instr( "vmov.32" , imm5 = 2 ) ) ]
1362
1354
#[ cfg_attr( all( test, target_arch = "aarch64" ) , assert_instr( mov, imm5 = 2 ) ) ]
1363
1355
pub unsafe fn vgetq_lane_u32 ( v : uint32x4_t , imm5 : i32 ) -> u32 {
1364
- if ( imm5) < 0 || ( imm5) > 3 {
1365
- unreachable_unchecked ( )
1366
- }
1367
- let imm5 = ( imm5 & 0b11 ) as u32 ;
1368
- simd_extract ( v, imm5)
1356
+ assert ! ( imm5 >= 0 && imm5 <= 3 ) ;
1357
+ simd_extract ( v, imm5 as u32 )
1358
+ }
1359
+
1360
+ /// Move vector element to general-purpose register
1361
+ #[ inline]
1362
+ #[ target_feature( enable = "neon" ) ]
1363
+ #[ cfg_attr( target_arch = "arm" , target_feature( enable = "v7" ) ) ]
1364
+ #[ rustc_args_required_const( 1 ) ]
1365
+ #[ cfg_attr( all( test, target_arch = "arm" ) , assert_instr( "vmov.32" , imm5 = 2 ) ) ]
1366
+ #[ cfg_attr( all( test, target_arch = "aarch64" ) , assert_instr( mov, imm5 = 2 ) ) ]
1367
+ pub unsafe fn vgetq_lane_s32 ( v : int32x4_t , imm5 : i32 ) -> i32 {
1368
+ assert ! ( imm5 >= 0 && imm5 <= 3 ) ;
1369
+ simd_extract ( v, imm5 as u32 )
1369
1370
}
1370
1371
1371
1372
/// Move vector element to general-purpose register
@@ -1376,11 +1377,8 @@ pub unsafe fn vgetq_lane_u32(v: uint32x4_t, imm5: i32) -> u32 {
1376
1377
#[ cfg_attr( all( test, target_arch = "arm" ) , assert_instr( "vmov.u8" , imm5 = 2 ) ) ]
1377
1378
#[ cfg_attr( all( test, target_arch = "aarch64" ) , assert_instr( umov, imm5 = 2 ) ) ]
1378
1379
pub unsafe fn vget_lane_u8 ( v : uint8x8_t , imm5 : i32 ) -> u8 {
1379
- if ( imm5) < 0 || ( imm5) > 7 {
1380
- unreachable_unchecked ( )
1381
- }
1382
- let imm5 = ( imm5 & 7 ) as u32 ;
1383
- simd_extract ( v, imm5)
1380
+ assert ! ( imm5 >= 0 && imm5 <= 7 ) ;
1381
+ simd_extract ( v, imm5 as u32 )
1384
1382
}
1385
1383
1386
1384
/// Duplicate vector element to vector or scalar
@@ -1892,6 +1890,13 @@ mod tests {
1892
1890
assert_eq ! ( r, 2 ) ;
1893
1891
}
1894
1892
1893
+ #[ simd_test( enable = "neon" ) ]
1894
+ unsafe fn test_vgetq_lane_s32 ( ) {
1895
+ let v = i32x4:: new ( 1 , 2 , 3 , 4 ) ;
1896
+ let r = vgetq_lane_s32 ( transmute ( v) , 1 ) ;
1897
+ assert_eq ! ( r, 2 ) ;
1898
+ }
1899
+
1895
1900
#[ simd_test( enable = "neon" ) ]
1896
1901
unsafe fn test_vget_lane_u64 ( ) {
1897
1902
let v: u64 = 1 ;
0 commit comments