Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit 36451e3

Browse files
committed
resolve warnings
update update
1 parent 1ff94d5 commit 36451e3

File tree

3 files changed

+17
-20
lines changed

3 files changed

+17
-20
lines changed

crates/libm-test/benches/random.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ libm_macros::for_each_function! {
126126
| fdimf128
127127
| fdimf16
128128
| floorf128
129+
| fmaf16
129130
| floorf16
130131
| rintf128
131132
| rintf16

crates/util/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ fn do_eval(basis: &str, op: &str, inputs: &[&str]) {
9696
| fdimf16
9797
| floorf128
9898
| floorf16
99+
| fmaf16
99100
| rintf128
100101
| rintf16
101102
| sqrtf128

src/math/generic/fma.rs

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,34 @@
1-
use super::super::fenv::{
2-
FE_INEXACT, FE_TONEAREST, FE_UNDERFLOW, feclearexcept, fegetround, feraiseexcept, fetestexcept,
3-
};
4-
use super::super::{CastFrom, CastInto, DFloat, Float, HFloat, Int, IntTy, MinInt};
1+
use super::super::fenv::{FE_TONEAREST, fegetround};
2+
use super::super::{CastFrom, CastInto, DFloat, Float, HFloat, IntTy, MinInt};
53

64
/// FMA implementation when a hardware-backed larger float type is available.
75
pub fn fma_big<F, B>(x: F, y: F, z: F) -> F
86
where
97
F: Float + HFloat<D = B>,
108
B: Float + DFloat<H = F>,
11-
// F: Float + CastInto<B>,
12-
// B: Float + CastInto<F> + CastFrom<F>,
139
B::Int: CastInto<i32>,
1410
i32: CastFrom<i32>,
1511
{
1612
let one = IntTy::<B>::ONE;
1713

18-
let xy: B;
19-
let mut result: B;
20-
let mut ui: B::Int;
21-
let e: i32;
22-
23-
xy = x.widen() * y.widen();
24-
result = xy + z.widen();
25-
ui = result.to_bits();
26-
e = result.exp().signed();
14+
let xy: B = x.widen() * y.widen();
15+
let result: B = xy + z.widen();
16+
let mut ui: B::Int = result.to_bits();
17+
let re = result.exp();
2718
let zb: B = z.widen();
2819

2920
let prec_diff = B::SIG_BITS - F::SIG_BITS;
3021
let excess_prec = ui & ((one << prec_diff) - one);
31-
let x = one << (prec_diff - 1);
32-
33-
// Common case: the larger precision is fine
34-
if excess_prec != x
35-
|| e == i32::cast_from(F::EXP_MAX)
22+
let halfway = one << (prec_diff - 1);
23+
24+
// Common case: the larger precision is fine if...
25+
// This is not a halfway case
26+
if excess_prec != halfway
27+
// Or the result is NaN
28+
|| re == B::EXP_MAX
29+
// Or the result is exact
3630
|| (result - xy == zb && result - zb == xy)
31+
// Or the mode is something other than round to nearest
3732
|| fegetround() != FE_TONEAREST
3833
{
3934
// TODO: feclearexcept

0 commit comments

Comments
 (0)