diff options
| author | Trevor Gross <tmgross@umich.edu> | 2025-02-07 01:05:38 +0000 |
|---|---|---|
| committer | Trevor Gross <tmgross@umich.edu> | 2025-02-07 02:47:06 +0000 |
| commit | f028611faf62a9b87430ff782ab0bb91d5c63a8f (patch) | |
| tree | 274817202e6237063b13c8c23e8e253352af838d | |
| parent | 69ebd750ccacd44fab4407501d568abd1e0801c1 (diff) | |
| download | rust-f028611faf62a9b87430ff782ab0bb91d5c63a8f.tar.gz rust-f028611faf62a9b87430ff782ab0bb91d5c63a8f.zip | |
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.
| -rw-r--r-- | library/compiler-builtins/libm/crates/libm-test/src/gen/edge_cases.rs | 20 | ||||
| -rw-r--r-- | library/compiler-builtins/libm/crates/libm-test/src/run_cfg.rs | 2 |
2 files changed, 20 insertions, 2 deletions
diff --git a/library/compiler-builtins/libm/crates/libm-test/src/gen/edge_cases.rs b/library/compiler-builtins/libm/crates/libm-test/src/gen/edge_cases.rs index 8da635114d2..69b59a10567 100644 --- a/library/compiler-builtins/libm/crates/libm-test/src/gen/edge_cases.rs +++ b/library/compiler-builtins/libm/crates/libm-test/src/gen/edge_cases.rs @@ -1,9 +1,10 @@ //! A generator that checks a handful of cases near infinities, zeros, asymptotes, and NaNs. -use libm::support::{CastInto, Float, Int}; +use libm::support::{CastInto, Float, Int, MinInt}; use crate::domain::get_domain; use crate::gen::KnownSize; +use crate::op::OpITy; use crate::run_cfg::{check_near_count, check_point_count}; use crate::{BaseName, CheckCtx, FloatExt, FloatTy, MathOp, test_log}; @@ -21,6 +22,7 @@ where Op: MathOp, { let mut ret = Vec::new(); + let one = OpITy::<Op>::ONE; let values = &mut ret; let domain = get_domain::<_, i8>(ctx.fn_ident, argnum).unwrap_float(); let domain_start = domain.range_start(); @@ -51,6 +53,22 @@ where values.push(Op::FTy::NAN); values.extend(Op::FTy::consts().iter()); + // Check around the maximum subnormal value + let sub_max = Op::FTy::from_bits(Op::FTy::SIG_MASK); + count_up(sub_max, near_points, values); + count_down(sub_max, near_points, values); + count_up(-sub_max, near_points, values); + count_down(-sub_max, near_points, values); + + // Check a few values around the subnormal range + for shift in (0..Op::FTy::SIG_BITS).step_by(Op::FTy::SIG_BITS as usize / 5) { + let v = Op::FTy::from_bits(one << shift); + count_up(v, 2, values); + count_down(v, 2, values); + count_up(-v, 2, values); + count_down(-v, 2, values); + } + // Check around asymptotes if let Some(f) = domain.check_points { let iter = f(); diff --git a/library/compiler-builtins/libm/crates/libm-test/src/run_cfg.rs b/library/compiler-builtins/libm/crates/libm-test/src/run_cfg.rs index 5728c3b2e5b..4dd43bdf386 100644 --- a/library/compiler-builtins/libm/crates/libm-test/src/run_cfg.rs +++ b/library/compiler-builtins/libm/crates/libm-test/src/run_cfg.rs @@ -342,7 +342,7 @@ pub fn check_near_count(ctx: &CheckCtx) -> u64 { x => panic!("unexpected argument count {x}"), } } else { - 10 + 8 } } |
