Skip to content

Commit 1997d18

Browse files
committed
use simd_cast in vcvt_s*_f*
1 parent 85718e2 commit 1997d18

File tree

4 files changed

+39
-152
lines changed

4 files changed

+39
-152
lines changed

crates/core_arch/src/aarch64/neon/generated.rs

Lines changed: 26 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,52 +1157,32 @@ pub unsafe fn vcvtx_high_f32_f64(a: float32x2_t, b: float64x2_t) -> float32x4_t
11571157
#[inline]
11581158
#[target_feature(enable = "neon")]
11591159
#[cfg_attr(test, assert_instr(fcvtzs))]
1160-
pub unsafe fn vcvt_s32_f32(a: float32x2_t) -> int32x2_t {
1161-
#[allow(improper_ctypes)]
1162-
extern "C" {
1163-
#[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.neon.fcvtzs.v2i32.v2f32")]
1164-
fn vcvt_s32_f32_(a: float32x2_t) -> int32x2_t;
1165-
}
1166-
vcvt_s32_f32_(a)
1160+
pub unsafe fn vcvt_s64_f64(a: float64x1_t) -> int64x1_t {
1161+
simd_cast(a)
11671162
}
11681163

11691164
/// Floating-point convert to signed fixed-point, rounding toward zero
11701165
#[inline]
11711166
#[target_feature(enable = "neon")]
11721167
#[cfg_attr(test, assert_instr(fcvtzs))]
1173-
pub unsafe fn vcvtq_s32_f32(a: float32x4_t) -> int32x4_t {
1174-
#[allow(improper_ctypes)]
1175-
extern "C" {
1176-
#[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.neon.fcvtzs.v4i32.v4f32")]
1177-
fn vcvtq_s32_f32_(a: float32x4_t) -> int32x4_t;
1178-
}
1179-
vcvtq_s32_f32_(a)
1168+
pub unsafe fn vcvtq_s64_f64(a: float64x2_t) -> int64x2_t {
1169+
simd_cast(a)
11801170
}
11811171

1182-
/// Floating-point convert to signed fixed-point, rounding toward zero
1172+
/// Floating-point convert to unsigned fixed-point, rounding toward zero
11831173
#[inline]
11841174
#[target_feature(enable = "neon")]
11851175
#[cfg_attr(test, assert_instr(fcvtzs))]
1186-
pub unsafe fn vcvt_s64_f64(a: float64x1_t) -> int64x1_t {
1187-
#[allow(improper_ctypes)]
1188-
extern "C" {
1189-
#[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.neon.fcvtzs.v1i64.v1f64")]
1190-
fn vcvt_s64_f64_(a: float64x1_t) -> int64x1_t;
1191-
}
1192-
vcvt_s64_f64_(a)
1176+
pub unsafe fn vcvt_u64_f64(a: float64x1_t) -> uint64x1_t {
1177+
simd_cast(a)
11931178
}
11941179

1195-
/// Floating-point convert to signed fixed-point, rounding toward zero
1180+
/// Floating-point convert to unsigned fixed-point, rounding toward zero
11961181
#[inline]
11971182
#[target_feature(enable = "neon")]
11981183
#[cfg_attr(test, assert_instr(fcvtzs))]
1199-
pub unsafe fn vcvtq_s64_f64(a: float64x2_t) -> int64x2_t {
1200-
#[allow(improper_ctypes)]
1201-
extern "C" {
1202-
#[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.neon.fcvtzs.v2i64.v2f64")]
1203-
fn vcvtq_s64_f64_(a: float64x2_t) -> int64x2_t;
1204-
}
1205-
vcvtq_s64_f64_(a)
1184+
pub unsafe fn vcvtq_u64_f64(a: float64x2_t) -> uint64x2_t {
1185+
simd_cast(a)
12061186
}
12071187

12081188
/// Floating-point convert to signed integer, rounding to nearest with ties to away
@@ -1413,58 +1393,6 @@ pub unsafe fn vcvtpq_s64_f64(a: float64x2_t) -> int64x2_t {
14131393
vcvtpq_s64_f64_(a)
14141394
}
14151395

1416-
/// Floating-point convert to unsigned fixed-point, rounding toward zero
1417-
#[inline]
1418-
#[target_feature(enable = "neon")]
1419-
#[cfg_attr(test, assert_instr(fcvtzu))]
1420-
pub unsafe fn vcvt_u32_f32(a: float32x2_t) -> uint32x2_t {
1421-
#[allow(improper_ctypes)]
1422-
extern "C" {
1423-
#[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.neon.fcvtzu.v2i32.v2f32")]
1424-
fn vcvt_u32_f32_(a: float32x2_t) -> uint32x2_t;
1425-
}
1426-
vcvt_u32_f32_(a)
1427-
}
1428-
1429-
/// Floating-point convert to unsigned fixed-point, rounding toward zero
1430-
#[inline]
1431-
#[target_feature(enable = "neon")]
1432-
#[cfg_attr(test, assert_instr(fcvtzu))]
1433-
pub unsafe fn vcvtq_u32_f32(a: float32x4_t) -> uint32x4_t {
1434-
#[allow(improper_ctypes)]
1435-
extern "C" {
1436-
#[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.neon.fcvtzu.v4i32.v4f32")]
1437-
fn vcvtq_u32_f32_(a: float32x4_t) -> uint32x4_t;
1438-
}
1439-
vcvtq_u32_f32_(a)
1440-
}
1441-
1442-
/// Floating-point convert to unsigned fixed-point, rounding toward zero
1443-
#[inline]
1444-
#[target_feature(enable = "neon")]
1445-
#[cfg_attr(test, assert_instr(fcvtzu))]
1446-
pub unsafe fn vcvt_u64_f64(a: float64x1_t) -> uint64x1_t {
1447-
#[allow(improper_ctypes)]
1448-
extern "C" {
1449-
#[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.neon.fcvtzu.v1i64.v1f64")]
1450-
fn vcvt_u64_f64_(a: float64x1_t) -> uint64x1_t;
1451-
}
1452-
vcvt_u64_f64_(a)
1453-
}
1454-
1455-
/// Floating-point convert to unsigned fixed-point, rounding toward zero
1456-
#[inline]
1457-
#[target_feature(enable = "neon")]
1458-
#[cfg_attr(test, assert_instr(fcvtzu))]
1459-
pub unsafe fn vcvtq_u64_f64(a: float64x2_t) -> uint64x2_t {
1460-
#[allow(improper_ctypes)]
1461-
extern "C" {
1462-
#[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.neon.fcvtzu.v2i64.v2f64")]
1463-
fn vcvtq_u64_f64_(a: float64x2_t) -> uint64x2_t;
1464-
}
1465-
vcvtq_u64_f64_(a)
1466-
}
1467-
14681396
/// Floating-point convert to unsigned integer, rounding to nearest with ties to away
14691397
#[inline]
14701398
#[target_feature(enable = "neon")]
@@ -2990,22 +2918,6 @@ mod test {
29902918
assert_eq!(r, e);
29912919
}
29922920

2993-
#[simd_test(enable = "neon")]
2994-
unsafe fn test_vcvt_s32_f32() {
2995-
let a: f32x2 = f32x2::new(-1.0, 2.0);
2996-
let e: i32x2 = i32x2::new(-1, 2);
2997-
let r: i32x2 = transmute(vcvt_s32_f32(transmute(a)));
2998-
assert_eq!(r, e);
2999-
}
3000-
3001-
#[simd_test(enable = "neon")]
3002-
unsafe fn test_vcvtq_s32_f32() {
3003-
let a: f32x4 = f32x4::new(-1.0, 2.0, -3.0, 4.0);
3004-
let e: i32x4 = i32x4::new(-1, 2, -3, 4);
3005-
let r: i32x4 = transmute(vcvtq_s32_f32(transmute(a)));
3006-
assert_eq!(r, e);
3007-
}
3008-
30092921
#[simd_test(enable = "neon")]
30102922
unsafe fn test_vcvt_s64_f64() {
30112923
let a: f64 = -1.0;
@@ -3022,6 +2934,22 @@ mod test {
30222934
assert_eq!(r, e);
30232935
}
30242936

2937+
#[simd_test(enable = "neon")]
2938+
unsafe fn test_vcvt_u64_f64() {
2939+
let a: f64 = 1.0;
2940+
let e: u64x1 = u64x1::new(1);
2941+
let r: u64x1 = transmute(vcvt_u64_f64(transmute(a)));
2942+
assert_eq!(r, e);
2943+
}
2944+
2945+
#[simd_test(enable = "neon")]
2946+
unsafe fn test_vcvtq_u64_f64() {
2947+
let a: f64x2 = f64x2::new(1.0, 2.0);
2948+
let e: u64x2 = u64x2::new(1, 2);
2949+
let r: u64x2 = transmute(vcvtq_u64_f64(transmute(a)));
2950+
assert_eq!(r, e);
2951+
}
2952+
30252953
#[simd_test(enable = "neon")]
30262954
unsafe fn test_vcvta_s32_f32() {
30272955
let a: f32x2 = f32x2::new(-1.0, 2.0);
@@ -3150,38 +3078,6 @@ mod test {
31503078
assert_eq!(r, e);
31513079
}
31523080

3153-
#[simd_test(enable = "neon")]
3154-
unsafe fn test_vcvt_u32_f32() {
3155-
let a: f32x2 = f32x2::new(1.0, 2.0);
3156-
let e: u32x2 = u32x2::new(1, 2);
3157-
let r: u32x2 = transmute(vcvt_u32_f32(transmute(a)));
3158-
assert_eq!(r, e);
3159-
}
3160-
3161-
#[simd_test(enable = "neon")]
3162-
unsafe fn test_vcvtq_u32_f32() {
3163-
let a: f32x4 = f32x4::new(1.0, 2.0, 3.0, 4.0);
3164-
let e: u32x4 = u32x4::new(1, 2, 3, 4);
3165-
let r: u32x4 = transmute(vcvtq_u32_f32(transmute(a)));
3166-
assert_eq!(r, e);
3167-
}
3168-
3169-
#[simd_test(enable = "neon")]
3170-
unsafe fn test_vcvt_u64_f64() {
3171-
let a: f64 = 1.0;
3172-
let e: u64x1 = u64x1::new(1);
3173-
let r: u64x1 = transmute(vcvt_u64_f64(transmute(a)));
3174-
assert_eq!(r, e);
3175-
}
3176-
3177-
#[simd_test(enable = "neon")]
3178-
unsafe fn test_vcvtq_u64_f64() {
3179-
let a: f64x2 = f64x2::new(1.0, 2.0);
3180-
let e: u64x2 = u64x2::new(1, 2);
3181-
let r: u64x2 = transmute(vcvtq_u64_f64(transmute(a)));
3182-
assert_eq!(r, e);
3183-
}
3184-
31853081
#[simd_test(enable = "neon")]
31863082
unsafe fn test_vcvta_u32_f32() {
31873083
let a: f32x2 = f32x2::new(1.0, 2.0);

crates/core_arch/src/arm/neon/generated.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1946,6 +1946,7 @@ pub unsafe fn vcaleq_f32(a: float32x4_t, b: float32x4_t) -> uint32x4_t {
19461946
#[target_feature(enable = "neon")]
19471947
#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
19481948
#[cfg_attr(all(test, target_arch = "arm"), assert_instr(vcvt))]
1949+
#[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(fcvtzs))]
19491950
pub unsafe fn vcvt_s32_f32(a: float32x2_t) -> int32x2_t {
19501951
simd_cast(a)
19511952
}
@@ -1955,6 +1956,7 @@ pub unsafe fn vcvt_s32_f32(a: float32x2_t) -> int32x2_t {
19551956
#[target_feature(enable = "neon")]
19561957
#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
19571958
#[cfg_attr(all(test, target_arch = "arm"), assert_instr(vcvt))]
1959+
#[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(fcvtzs))]
19581960
pub unsafe fn vcvtq_s32_f32(a: float32x4_t) -> int32x4_t {
19591961
simd_cast(a)
19601962
}
@@ -1964,6 +1966,7 @@ pub unsafe fn vcvtq_s32_f32(a: float32x4_t) -> int32x4_t {
19641966
#[target_feature(enable = "neon")]
19651967
#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
19661968
#[cfg_attr(all(test, target_arch = "arm"), assert_instr(vcvt))]
1969+
#[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(fcvtzs))]
19671970
pub unsafe fn vcvt_u32_f32(a: float32x2_t) -> uint32x2_t {
19681971
simd_cast(a)
19691972
}
@@ -1973,6 +1976,7 @@ pub unsafe fn vcvt_u32_f32(a: float32x2_t) -> uint32x2_t {
19731976
#[target_feature(enable = "neon")]
19741977
#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
19751978
#[cfg_attr(all(test, target_arch = "arm"), assert_instr(vcvt))]
1979+
#[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(fcvtzs))]
19761980
pub unsafe fn vcvtq_u32_f32(a: float32x4_t) -> uint32x4_t {
19771981
simd_cast(a)
19781982
}

crates/stdarch-gen/neon.spec

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,9 @@ fn = simd_cast
659659
a = -1.0, 2.0, -3.0, 4.0
660660
validate -1, 2, -3, 4
661661

662+
aarch64 = fcvtzs
663+
generate float64x1_t:int64x1_t, float64x2_t:int64x2_t
664+
662665
arm = vcvt
663666
generate float32x2_t:int32x2_t, float32x4_t:int32x4_t
664667

@@ -669,19 +672,12 @@ fn = simd_cast
669672
a = 1.0, 2.0, 3.0, 4.0
670673
validate 1, 2, 3, 4
671674

675+
aarch64 = fcvtzs
676+
generate float64x1_t:uint64x1_t, float64x2_t:uint64x2_t
677+
672678
arm = vcvt
673679
generate float32x2_t:uint32x2_t, float32x4_t:uint32x4_t
674680

675-
/// Floating-point convert to signed fixed-point, rounding toward zero
676-
name = vcvt
677-
double-suffixes
678-
a = -1.0, 2.0, -3.0, 4.0
679-
validate -1, 2, -3, 4
680-
681-
aarch64 = fcvtzs
682-
link-aarch64 = fcvtzs._EXT2_._EXT_
683-
generate float32x2_t:int32x2_t, float32x4_t:int32x4_t, float64x1_t:int64x1_t, float64x2_t:int64x2_t
684-
685681
/// Floating-point convert to signed integer, rounding to nearest with ties to away
686682
name = vcvta
687683
double-suffixes
@@ -722,16 +718,6 @@ aarch64 = fcvtps
722718
link-aarch64 = fcvtps._EXT2_._EXT_
723719
generate float32x2_t:int32x2_t, float32x4_t:int32x4_t, float64x1_t:int64x1_t, float64x2_t:int64x2_t
724720

725-
/// Floating-point convert to unsigned fixed-point, rounding toward zero
726-
name = vcvt
727-
double-suffixes
728-
a = 1.0, 2.0, 3.0, 4.0
729-
validate 1, 2, 3, 4
730-
731-
aarch64 = fcvtzu
732-
link-aarch64 = fcvtzu._EXT2_._EXT_
733-
generate float32x2_t:uint32x2_t, float32x4_t:uint32x4_t, float64x1_t:uint64x1_t, float64x2_t:uint64x2_t
734-
735721
/// Floating-point convert to unsigned integer, rounding to nearest with ties to away
736722
name = vcvta
737723
double-suffixes

crates/stdarch-gen/src/main.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,7 +1190,7 @@ mod test {
11901190
tests_aarch64.push('}');
11911191
tests_aarch64.push('\n');
11921192

1193-
let arm_out_path: PathBuf = PathBuf::from(env::var("OUT_DIR").unwrap())
1193+
let arm_out_path: PathBuf = PathBuf::from("./crates/core_arch")
11941194
.join("src")
11951195
.join("arm")
11961196
.join("neon");
@@ -1200,7 +1200,8 @@ mod test {
12001200
file_arm.write_all(out_arm.as_bytes())?;
12011201
file_arm.write_all(tests_arm.as_bytes())?;
12021202

1203-
let aarch64_out_path: PathBuf = PathBuf::from(env::var("OUT_DIR").unwrap())
1203+
//let aarch64_out_path: PathBuf = PathBuf::from(env::var("OUT_DIR").unwrap())
1204+
let aarch64_out_path: PathBuf = PathBuf::from("./crates/core_arch")
12041205
.join("src")
12051206
.join("aarch64")
12061207
.join("neon");

0 commit comments

Comments
 (0)