Skip to content

Commit 6413d9b

Browse files
committed
disable floating point testing on some architectures
1 parent 572a6b1 commit 6413d9b

File tree

8 files changed

+25
-12
lines changed

8 files changed

+25
-12
lines changed

src/float/div.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use float::Float;
2-
use int::{CastInto, Int, HInt, DInt};
2+
use int::{CastInto, DInt, HInt, Int};
33

44
fn div32<F: Float>(a: F, b: F) -> F
55
where

src/float/mul.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use float::Float;
2-
use int::{CastInto, Int, HInt, DInt};
2+
use int::{CastInto, DInt, HInt, Int};
33

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

117119
let a_exponent_i32: i32 = a_exponent.cast();
118120
let b_exponent_i32: i32 = b_exponent.cast();

testcrate/build.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -648,10 +648,7 @@ fn main() {
648648
return None;
649649
}
650650
let c = a.0 / b.0;
651-
if a.0.is_nan()
652-
|| b.0.is_nan()
653-
|| c.is_nan()
654-
|| c.abs() <= f32::from_bits(16777215u32)
651+
if a.0.is_nan() || b.0.is_nan() || c.is_nan() || c.abs() <= f32::from_bits(16777215u32)
655652
{
656653
None
657654
} else {

testcrate/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
//! encounter. The randomized fuzz testing is specially designed to cover wide swaths of search
1010
//! space in as few iterations as possible. See `fuzz_values` in `testcrate/tests/misc.rs` for an
1111
//! example.
12+
//!
13+
//! Some floating point tests are disabled on x86 architectures without SSE, because they do not
14+
//! have correct rounding.
1215
#![no_std]
1316

1417
use compiler_builtins::float::Float;

testcrate/tests/addsub.rs

+1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ macro_rules! float_sum {
9191
};
9292
}
9393

94+
#[cfg(not(all(target_arch = "x86", not(target_feature = "sse"))))]
9495
#[test]
9596
fn float_addsub() {
9697
use compiler_builtins::float::{

testcrate/tests/conv.rs

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ macro_rules! i_to_f {
1212
};
1313
}
1414

15+
#[cfg(not(all(target_arch = "x86", not(target_feature = "sse"))))]
1516
#[test]
1617
fn int_to_float() {
1718
use compiler_builtins::float::conv::{

testcrate/tests/div_rem.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
use compiler_builtins::int::sdiv::{__divmoddi4, __divmodsi4, __divmodti4};
22
use compiler_builtins::int::udiv::{__udivmoddi4, __udivmodsi4, __udivmodti4, u128_divide_sparc};
33

4+
// Division algorithms have by far the nastiest and largest number of edge cases, and experience shows
5+
// that sometimes 100_000 iterations of the random fuzzer is needed.
6+
47
/// Creates intensive test functions for division functions of a certain size
58
macro_rules! test {
69
(
@@ -97,7 +100,6 @@ fn divide_sparc() {
97100
});
98101
}
99102

100-
101103
macro_rules! float {
102104
($n:expr, $($i:ty, $fn:ident);*;) => {
103105
$(
@@ -118,13 +120,16 @@ macro_rules! float {
118120
};
119121
}
120122

123+
#[cfg(not(all(target_arch = "x86", not(target_feature = "sse"))))]
121124
#[test]
122125
fn float_div() {
123-
use compiler_builtins::float::{Float, div::{__divsf3, __divdf3}};
126+
use compiler_builtins::float::{
127+
div::{__divdf3, __divsf3},
128+
Float,
129+
};
124130

125-
float!(10_000,
131+
float!(100_000,
126132
f32, __divsf3;
127133
f64, __divdf3;
128134
);
129135
}
130-

testcrate/tests/mul.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,13 @@ macro_rules! float_mul {
9797
};
9898
}
9999

100+
#[cfg(not(all(target_arch = "x86", not(target_feature = "sse"))))]
100101
#[test]
101102
fn float_mul() {
102-
use compiler_builtins::float::{Float, mul::{__mulsf3, __muldf3}};
103+
use compiler_builtins::float::{
104+
mul::{__muldf3, __mulsf3},
105+
Float,
106+
};
103107

104108
float_mul!(10_000,
105109
f32, __mulsf3;

0 commit comments

Comments
 (0)