]> git.lizzy.rs Git - rust.git/blob - src/tools/miri/tests/pass/float_fast_math.rs
Auto merge of #104915 - weihanglo:update-cargo, r=ehuss
[rust.git] / src / tools / miri / tests / pass / float_fast_math.rs
1 #![feature(core_intrinsics)]
2
3 use std::intrinsics::{fadd_fast, fdiv_fast, fmul_fast, frem_fast, fsub_fast};
4
5 #[inline(never)]
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) {
19     // make sure they all map to the correct operation
20     unsafe {
21         assert_eq!(fadd_fast(a, b), a + b);
22         assert_eq!(fsub_fast(a, b), a - b);
23         assert_eq!(fmul_fast(a, b), a * b);
24         assert_eq!(fdiv_fast(a, b), a / b);
25         assert_eq!(frem_fast(a, b), a % b);
26     }
27 }
28
29 fn main() {
30     test_operations_f64(1., 2.);
31     test_operations_f64(10., 5.);
32     test_operations_f32(11., 2.);
33     test_operations_f32(10., 15.);
34 }