Skip to content

Commit 1619c70

Browse files
authored
Add vdiv neon instructions (#1077)
1 parent 8724eb4 commit 1619c70

File tree

2 files changed

+77
-0
lines changed

2 files changed

+77
-0
lines changed

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

+68
Original file line numberDiff line numberDiff line change
@@ -1031,6 +1031,38 @@ pub unsafe fn vmulq_f64(a: float64x2_t, b: float64x2_t) -> float64x2_t {
10311031
simd_mul(a, b)
10321032
}
10331033

1034+
/// Divide
1035+
#[inline]
1036+
#[target_feature(enable = "neon")]
1037+
#[cfg_attr(test, assert_instr(fdiv))]
1038+
pub unsafe fn vdiv_f32(a: float32x2_t, b: float32x2_t) -> float32x2_t {
1039+
simd_div(a, b)
1040+
}
1041+
1042+
/// Divide
1043+
#[inline]
1044+
#[target_feature(enable = "neon")]
1045+
#[cfg_attr(test, assert_instr(fdiv))]
1046+
pub unsafe fn vdivq_f32(a: float32x4_t, b: float32x4_t) -> float32x4_t {
1047+
simd_div(a, b)
1048+
}
1049+
1050+
/// Divide
1051+
#[inline]
1052+
#[target_feature(enable = "neon")]
1053+
#[cfg_attr(test, assert_instr(fdiv))]
1054+
pub unsafe fn vdiv_f64(a: float64x1_t, b: float64x1_t) -> float64x1_t {
1055+
simd_div(a, b)
1056+
}
1057+
1058+
/// Divide
1059+
#[inline]
1060+
#[target_feature(enable = "neon")]
1061+
#[cfg_attr(test, assert_instr(fdiv))]
1062+
pub unsafe fn vdivq_f64(a: float64x2_t, b: float64x2_t) -> float64x2_t {
1063+
simd_div(a, b)
1064+
}
1065+
10341066
/// Subtract
10351067
#[inline]
10361068
#[target_feature(enable = "neon")]
@@ -2112,6 +2144,42 @@ mod test {
21122144
assert_eq!(r, e);
21132145
}
21142146

2147+
#[simd_test(enable = "neon")]
2148+
unsafe fn test_vdiv_f32() {
2149+
let a: f32x2 = f32x2::new(2.0, 6.0);
2150+
let b: f32x2 = f32x2::new(1.0, 2.0);
2151+
let e: f32x2 = f32x2::new(2.0, 3.0);
2152+
let r: f32x2 = transmute(vdiv_f32(transmute(a), transmute(b)));
2153+
assert_eq!(r, e);
2154+
}
2155+
2156+
#[simd_test(enable = "neon")]
2157+
unsafe fn test_vdivq_f32() {
2158+
let a: f32x4 = f32x4::new(2.0, 6.0, 4.0, 10.0);
2159+
let b: f32x4 = f32x4::new(1.0, 2.0, 1.0, 2.0);
2160+
let e: f32x4 = f32x4::new(2.0, 3.0, 4.0, 5.0);
2161+
let r: f32x4 = transmute(vdivq_f32(transmute(a), transmute(b)));
2162+
assert_eq!(r, e);
2163+
}
2164+
2165+
#[simd_test(enable = "neon")]
2166+
unsafe fn test_vdiv_f64() {
2167+
let a: f64 = 2.0;
2168+
let b: f64 = 1.0;
2169+
let e: f64 = 2.0;
2170+
let r: f64 = transmute(vdiv_f64(transmute(a), transmute(b)));
2171+
assert_eq!(r, e);
2172+
}
2173+
2174+
#[simd_test(enable = "neon")]
2175+
unsafe fn test_vdivq_f64() {
2176+
let a: f64x2 = f64x2::new(2.0, 6.0);
2177+
let b: f64x2 = f64x2::new(1.0, 2.0);
2178+
let e: f64x2 = f64x2::new(2.0, 3.0);
2179+
let r: f64x2 = transmute(vdivq_f64(transmute(a), transmute(b)));
2180+
assert_eq!(r, e);
2181+
}
2182+
21152183
#[simd_test(enable = "neon")]
21162184
unsafe fn test_vsub_f64() {
21172185
let a: f64 = 1.0;

crates/stdarch-gen/neon.spec

+9
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,15 @@ generate float64x*_t
601601
arm = vmul.
602602
generate float*_t
603603

604+
/// Divide
605+
name = vdiv
606+
fn = simd_div
607+
a = 2.0, 6.0, 4.0, 10.0
608+
b = 1.0, 2.0, 1.0, 2.0
609+
validate 2.0, 3.0, 4.0, 5.0
610+
611+
aarch64 = fdiv
612+
generate float*_t, float64x*_t
604613

605614
/// Subtract
606615
name = vsub

0 commit comments

Comments
 (0)