Skip to content

Commit 0fbdb7b

Browse files
committed
Check more subnormal values during edge cases tests
Add checks at the max subnormal value and a couple values scatted throughout the subnormal range. This helped identifiy a bug in `fmaf128`. As part of this, slightly reduce the amount of edge cases checked without optimizations because the change makes it become noticible.
1 parent 34cd8f6 commit 0fbdb7b

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

crates/libm-test/src/gen/edge_cases.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
//! A generator that checks a handful of cases near infinities, zeros, asymptotes, and NaNs.
22
3-
use libm::support::{CastInto, Float, Int};
3+
use libm::support::{CastInto, Float, Int, MinInt};
44

55
use crate::domain::get_domain;
66
use crate::gen::KnownSize;
7+
use crate::op::OpITy;
78
use crate::run_cfg::{check_near_count, check_point_count};
89
use crate::{BaseName, CheckCtx, FloatExt, FloatTy, MathOp, test_log};
910

@@ -21,6 +22,7 @@ where
2122
Op: MathOp,
2223
{
2324
let mut ret = Vec::new();
25+
let one = OpITy::<Op>::ONE;
2426
let values = &mut ret;
2527
let domain = get_domain::<_, i8>(ctx.fn_ident, argnum).unwrap_float();
2628
let domain_start = domain.range_start();
@@ -51,6 +53,22 @@ where
5153
values.push(Op::FTy::NAN);
5254
values.extend(Op::FTy::consts().iter());
5355

56+
// Check around the maximum subnormal value
57+
let sub_max = Op::FTy::from_bits(Op::FTy::SIG_MASK);
58+
count_up(sub_max, near_points, values);
59+
count_down(sub_max, near_points, values);
60+
count_up(-sub_max, near_points, values);
61+
count_down(-sub_max, near_points, values);
62+
63+
// Check a few values around the subnormal range
64+
for shift in (0..Op::FTy::SIG_BITS).step_by(Op::FTy::SIG_BITS as usize / 5) {
65+
let v = Op::FTy::from_bits(one << shift);
66+
count_up(v, 2, values);
67+
count_down(v, 2, values);
68+
count_up(-v, 2, values);
69+
count_down(-v, 2, values);
70+
}
71+
5472
// Check around asymptotes
5573
if let Some(f) = domain.check_points {
5674
let iter = f();

crates/libm-test/src/run_cfg.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ pub fn check_near_count(ctx: &CheckCtx) -> u64 {
342342
x => panic!("unexpected argument count {x}"),
343343
}
344344
} else {
345-
10
345+
8
346346
}
347347
}
348348

0 commit comments

Comments
 (0)