From aeda5a8b8acf98c631f5c899882be0bf6b310539 Mon Sep 17 00:00:00 2001 From: itsjunetime Date: Tue, 31 Mar 2026 18:03:35 -0500 Subject: [PATCH 1/2] Use current-nightly arm simd fns and adjust test answers to current llvm answers --- simd/src/arm/mod.rs | 12 ++++++------ simd/src/test.rs | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/simd/src/arm/mod.rs b/simd/src/arm/mod.rs index c39380b2..43d410ec 100644 --- a/simd/src/arm/mod.rs +++ b/simd/src/arm/mod.rs @@ -79,12 +79,12 @@ impl F32x2 { #[inline] pub fn min(self, other: F32x2) -> F32x2 { - unsafe { F32x2(simd_fmin(self.0, other.0)) } + unsafe { F32x2(simd_minimum_number_nsz(self.0, other.0)) } } #[inline] pub fn max(self, other: F32x2) -> F32x2 { - unsafe { F32x2(simd_fmax(self.0, other.0)) } + unsafe { F32x2(simd_maximum_number_nsz(self.0, other.0)) } } #[inline] @@ -268,12 +268,12 @@ impl F32x4 { #[inline] pub fn min(self, other: F32x4) -> F32x4 { - unsafe { F32x4(simd_fmin(self.0, other.0)) } + unsafe { F32x4(simd_minimum_number_nsz(self.0, other.0)) } } #[inline] pub fn max(self, other: F32x4) -> F32x4 { - unsafe { F32x4(simd_fmax(self.0, other.0)) } + unsafe { F32x4(simd_maximum_number_nsz(self.0, other.0)) } } #[inline] @@ -604,12 +604,12 @@ impl I32x4 { #[inline] pub fn max(self, other: I32x4) -> I32x4 { - unsafe { I32x4(simd_cast(simd_fmax(self.to_f32x4().0, other.to_f32x4().0))) } + unsafe { I32x4(simd_cast(simd_maximum_number_nsz(self.to_f32x4().0, other.to_f32x4().0))) } } #[inline] pub fn min(self, other: I32x4) -> I32x4 { - unsafe { I32x4(simd_cast(simd_fmin(self.to_f32x4().0, other.to_f32x4().0))) } + unsafe { I32x4(simd_cast(simd_minimum_number_nsz(self.to_f32x4().0, other.to_f32x4().0))) } } // Packed comparisons diff --git a/simd/src/test.rs b/simd/src/test.rs index 07d45513..da864918 100644 --- a/simd/src/test.rs +++ b/simd/src/test.rs @@ -37,7 +37,7 @@ fn test_f32x4_accessors_and_mutators() { fn test_f32x4_basic_ops() { let a = F32x4::new(1.0, 3.0, 5.0, 7.0); let b = F32x4::new(2.0, 2.0, 6.0, 6.0); - assert_eq!(a.approx_recip(), F32x4::new(0.99975586, 0.333313, 0.19995117, 0.14282227)); + assert_eq!(a.approx_recip(), F32x4::new(0.9980469, 0.3330078, 0.19970703, 0.14257813)); assert_eq!(a.min(b), F32x4::new(1.0, 2.0, 5.0, 6.0)); assert_eq!(a.max(b), F32x4::new(2.0, 3.0, 6.0, 7.0)); let c = F32x4::new(-1.0, 1.3, -20.0, 3.6); From 814671e162a1829e074521446317b915311d3d4d Mon Sep 17 00:00:00 2001 From: itsjunetime Date: Tue, 31 Mar 2026 18:18:39 -0500 Subject: [PATCH 2/2] Make reciprocal test compare within range instead of against exact values --- simd/src/test.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/simd/src/test.rs b/simd/src/test.rs index da864918..0f287525 100644 --- a/simd/src/test.rs +++ b/simd/src/test.rs @@ -37,7 +37,17 @@ fn test_f32x4_accessors_and_mutators() { fn test_f32x4_basic_ops() { let a = F32x4::new(1.0, 3.0, 5.0, 7.0); let b = F32x4::new(2.0, 2.0, 6.0, 6.0); - assert_eq!(a.approx_recip(), F32x4::new(0.9980469, 0.3330078, 0.19970703, 0.14257813)); + let approx_recip = a.approx_recip(); + + // The greatest diff we observe between the correct answer to the reciprocal and the answer that + // llvm gives us is 1.0 vs 0.9980469, so we need to have the allowable diff be 0.002 so that it + // passes. It's approximate, so it's fine to be a bit off. + const ALLOWABLE_RECIP_DIFF: f32 = 0.002; + assert!((approx_recip[0] - (1. / 1.)).abs() < ALLOWABLE_RECIP_DIFF); + assert!((approx_recip[1] - (1. / 3.)).abs() < ALLOWABLE_RECIP_DIFF); + assert!((approx_recip[2] - (1. / 5.)).abs() < ALLOWABLE_RECIP_DIFF); + assert!((approx_recip[3] - (1. / 7.)).abs() < ALLOWABLE_RECIP_DIFF); + assert_eq!(a.min(b), F32x4::new(1.0, 2.0, 5.0, 6.0)); assert_eq!(a.max(b), F32x4::new(2.0, 3.0, 6.0, 7.0)); let c = F32x4::new(-1.0, 1.3, -20.0, 3.6);