Skip to content

Commit ae70f36

Browse files
authored
Fix ARM nightly compilation (#583)
* Use current-nightly arm simd fns and adjust test answers to current llvm answers * Make reciprocal test compare within range instead of against exact values
1 parent 3d0b936 commit ae70f36

2 files changed

Lines changed: 17 additions & 7 deletions

File tree

simd/src/arm/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,12 @@ impl F32x2 {
7979

8080
#[inline]
8181
pub fn min(self, other: F32x2) -> F32x2 {
82-
unsafe { F32x2(simd_fmin(self.0, other.0)) }
82+
unsafe { F32x2(simd_minimum_number_nsz(self.0, other.0)) }
8383
}
8484

8585
#[inline]
8686
pub fn max(self, other: F32x2) -> F32x2 {
87-
unsafe { F32x2(simd_fmax(self.0, other.0)) }
87+
unsafe { F32x2(simd_maximum_number_nsz(self.0, other.0)) }
8888
}
8989

9090
#[inline]
@@ -268,12 +268,12 @@ impl F32x4 {
268268

269269
#[inline]
270270
pub fn min(self, other: F32x4) -> F32x4 {
271-
unsafe { F32x4(simd_fmin(self.0, other.0)) }
271+
unsafe { F32x4(simd_minimum_number_nsz(self.0, other.0)) }
272272
}
273273

274274
#[inline]
275275
pub fn max(self, other: F32x4) -> F32x4 {
276-
unsafe { F32x4(simd_fmax(self.0, other.0)) }
276+
unsafe { F32x4(simd_maximum_number_nsz(self.0, other.0)) }
277277
}
278278

279279
#[inline]
@@ -604,12 +604,12 @@ impl I32x4 {
604604

605605
#[inline]
606606
pub fn max(self, other: I32x4) -> I32x4 {
607-
unsafe { I32x4(simd_cast(simd_fmax(self.to_f32x4().0, other.to_f32x4().0))) }
607+
unsafe { I32x4(simd_cast(simd_maximum_number_nsz(self.to_f32x4().0, other.to_f32x4().0))) }
608608
}
609609

610610
#[inline]
611611
pub fn min(self, other: I32x4) -> I32x4 {
612-
unsafe { I32x4(simd_cast(simd_fmin(self.to_f32x4().0, other.to_f32x4().0))) }
612+
unsafe { I32x4(simd_cast(simd_minimum_number_nsz(self.to_f32x4().0, other.to_f32x4().0))) }
613613
}
614614

615615
// Packed comparisons

simd/src/test.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,17 @@ fn test_f32x4_accessors_and_mutators() {
3737
fn test_f32x4_basic_ops() {
3838
let a = F32x4::new(1.0, 3.0, 5.0, 7.0);
3939
let b = F32x4::new(2.0, 2.0, 6.0, 6.0);
40-
assert_eq!(a.approx_recip(), F32x4::new(0.99975586, 0.333313, 0.19995117, 0.14282227));
40+
let approx_recip = a.approx_recip();
41+
42+
// The greatest diff we observe between the correct answer to the reciprocal and the answer that
43+
// llvm gives us is 1.0 vs 0.9980469, so we need to have the allowable diff be 0.002 so that it
44+
// passes. It's approximate, so it's fine to be a bit off.
45+
const ALLOWABLE_RECIP_DIFF: f32 = 0.002;
46+
assert!((approx_recip[0] - (1. / 1.)).abs() < ALLOWABLE_RECIP_DIFF);
47+
assert!((approx_recip[1] - (1. / 3.)).abs() < ALLOWABLE_RECIP_DIFF);
48+
assert!((approx_recip[2] - (1. / 5.)).abs() < ALLOWABLE_RECIP_DIFF);
49+
assert!((approx_recip[3] - (1. / 7.)).abs() < ALLOWABLE_RECIP_DIFF);
50+
4151
assert_eq!(a.min(b), F32x4::new(1.0, 2.0, 5.0, 6.0));
4252
assert_eq!(a.max(b), F32x4::new(2.0, 3.0, 6.0, 7.0));
4353
let c = F32x4::new(-1.0, 1.3, -20.0, 3.6);

0 commit comments

Comments
 (0)