Skip to content

Commit

Permalink
disable floating point testing on some architectures
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronKutch committed Dec 5, 2020
1 parent 572a6b1 commit 6413d9b
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/float/div.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use float::Float;
use int::{CastInto, Int, HInt, DInt};
use int::{CastInto, DInt, HInt, Int};

fn div32<F: Float>(a: F, b: F) -> F
where
Expand Down
6 changes: 4 additions & 2 deletions src/float/mul.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use float::Float;
use int::{CastInto, Int, HInt, DInt};
use int::{CastInto, DInt, HInt, Int};

fn mul<F: Float>(a: F, b: F) -> F
where
Expand Down Expand Up @@ -112,7 +112,9 @@ where
// have (exponentBits + 2) integral digits, all but two of which must be
// zero. Normalizing this result is just a conditional left-shift by one
// and bumping the exponent accordingly.
let (mut product_low, mut product_high) = a_significand.widen_mul(b_significand << exponent_bits).lo_hi();
let (mut product_low, mut product_high) = a_significand
.widen_mul(b_significand << exponent_bits)
.lo_hi();

let a_exponent_i32: i32 = a_exponent.cast();
let b_exponent_i32: i32 = b_exponent.cast();
Expand Down
5 changes: 1 addition & 4 deletions testcrate/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -648,10 +648,7 @@ fn main() {
return None;
}
let c = a.0 / b.0;
if a.0.is_nan()
|| b.0.is_nan()
|| c.is_nan()
|| c.abs() <= f32::from_bits(16777215u32)
if a.0.is_nan() || b.0.is_nan() || c.is_nan() || c.abs() <= f32::from_bits(16777215u32)
{
None
} else {
Expand Down
3 changes: 3 additions & 0 deletions testcrate/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
//! encounter. The randomized fuzz testing is specially designed to cover wide swaths of search
//! space in as few iterations as possible. See `fuzz_values` in `testcrate/tests/misc.rs` for an
//! example.
//!
//! Some floating point tests are disabled on x86 architectures without SSE, because they do not
//! have correct rounding.
#![no_std]

use compiler_builtins::float::Float;
Expand Down
1 change: 1 addition & 0 deletions testcrate/tests/addsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ macro_rules! float_sum {
};
}

#[cfg(not(all(target_arch = "x86", not(target_feature = "sse"))))]
#[test]
fn float_addsub() {
use compiler_builtins::float::{
Expand Down
1 change: 1 addition & 0 deletions testcrate/tests/conv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ macro_rules! i_to_f {
};
}

#[cfg(not(all(target_arch = "x86", not(target_feature = "sse"))))]
#[test]
fn int_to_float() {
use compiler_builtins::float::conv::{
Expand Down
13 changes: 9 additions & 4 deletions testcrate/tests/div_rem.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use compiler_builtins::int::sdiv::{__divmoddi4, __divmodsi4, __divmodti4};
use compiler_builtins::int::udiv::{__udivmoddi4, __udivmodsi4, __udivmodti4, u128_divide_sparc};

// Division algorithms have by far the nastiest and largest number of edge cases, and experience shows
// that sometimes 100_000 iterations of the random fuzzer is needed.

/// Creates intensive test functions for division functions of a certain size
macro_rules! test {
(
Expand Down Expand Up @@ -97,7 +100,6 @@ fn divide_sparc() {
});
}


macro_rules! float {
($n:expr, $($i:ty, $fn:ident);*;) => {
$(
Expand All @@ -118,13 +120,16 @@ macro_rules! float {
};
}

#[cfg(not(all(target_arch = "x86", not(target_feature = "sse"))))]
#[test]
fn float_div() {
use compiler_builtins::float::{Float, div::{__divsf3, __divdf3}};
use compiler_builtins::float::{
div::{__divdf3, __divsf3},
Float,
};

float!(10_000,
float!(100_000,
f32, __divsf3;
f64, __divdf3;
);
}

6 changes: 5 additions & 1 deletion testcrate/tests/mul.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,13 @@ macro_rules! float_mul {
};
}

#[cfg(not(all(target_arch = "x86", not(target_feature = "sse"))))]
#[test]
fn float_mul() {
use compiler_builtins::float::{Float, mul::{__mulsf3, __muldf3}};
use compiler_builtins::float::{
mul::{__muldf3, __mulsf3},
Float,
};

float_mul!(10_000,
f32, __mulsf3;
Expand Down

0 comments on commit 6413d9b

Please sign in to comment.