Skip to content

Commit e5e0ced

Browse files
committed
smoketest f32 fast-math intrinsics
1 parent faff175 commit e5e0ced

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

tests/run-pass/float_fast_math.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,19 @@
33
use std::intrinsics::{fadd_fast, fsub_fast, fmul_fast, fdiv_fast, frem_fast};
44

55
#[inline(never)]
6-
pub fn test_operations(a: f64, b: f64) {
6+
pub fn test_operations_f64(a: f64, b: f64) {
7+
// make sure they all map to the correct operation
8+
unsafe {
9+
assert_eq!(fadd_fast(a, b), a + b);
10+
assert_eq!(fsub_fast(a, b), a - b);
11+
assert_eq!(fmul_fast(a, b), a * b);
12+
assert_eq!(fdiv_fast(a, b), a / b);
13+
assert_eq!(frem_fast(a, b), a % b);
14+
}
15+
}
16+
17+
#[inline(never)]
18+
pub fn test_operations_f32(a: f32, b: f32) {
719
// make sure they all map to the correct operation
820
unsafe {
921
assert_eq!(fadd_fast(a, b), a + b);
@@ -15,6 +27,8 @@ pub fn test_operations(a: f64, b: f64) {
1527
}
1628

1729
fn main() {
18-
test_operations(1., 2.);
19-
test_operations(10., 5.);
30+
test_operations_f64(1., 2.);
31+
test_operations_f64(10., 5.);
32+
test_operations_f32(11., 2.);
33+
test_operations_f32(10., 15.);
2034
}

0 commit comments

Comments
 (0)