Skip to content

Commit 348558e

Browse files
committed
Add a fuzzy comparison test for f32
1 parent 4b9746a commit 348558e

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

crates/core_arch/src/powerpc/altivec.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1774,6 +1774,17 @@ mod tests {
17741774
}
17751775

17761776
macro_rules! test_vec_1 {
1777+
{ $name: ident, $fn:ident, f32x4, [$($a:expr),+], ~[$($d:expr),+] } => {
1778+
#[simd_test(enable = "altivec")]
1779+
unsafe fn $name() {
1780+
let a: vector_float = transmute(f32x4::new($($a),+));
1781+
1782+
let d: vector_float = transmute(f32x4::new($($d),+));
1783+
let r = transmute(vec_cmple(vec_abs(vec_sub($fn(a), d)), vec_splats(std::f32::EPSILON)));
1784+
let e = m32x4::new(true, true, true, true);
1785+
assert_eq!(e, r);
1786+
}
1787+
};
17771788
{ $name: ident, $fn:ident, $ty: ident, [$($a:expr),+], [$($d:expr),+] } => {
17781789
test_vec_1! { $name, $fn, $ty -> $ty, [$($a),+], [$($d),+] }
17791790
};
@@ -1790,8 +1801,8 @@ mod tests {
17901801
}
17911802

17921803
test_vec_1! { test_vec_expte, vec_expte, f32x4,
1793-
[0.0, 2.0, 4.0, -1.0],
1794-
[1.0, 4.0, 16.0, 0.5]
1804+
[0.0, 2.0, 2.0, -1.0],
1805+
~[1.0, 4.0, 4.0, 0.5]
17951806
}
17961807

17971808
test_vec_2! { test_vec_cmpgt_i8, vec_cmpgt, i8x16 -> m8x16,

0 commit comments

Comments
 (0)