about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTrevor Gross <tmgross@umich.edu>2025-02-11 07:45:14 +0000
committerTrevor Gross <t.gross35@gmail.com>2025-02-11 02:27:13 -0600
commit7db47c741c173b94730b3017851924b1e7525dea (patch)
tree562cceaf47067934b5f36b6720407c7510a269fe
parent53a055049cde50f6a42cf3cb5a7826142ea396e0 (diff)
downloadrust-7db47c741c173b94730b3017851924b1e7525dea.tar.gz
rust-7db47c741c173b94730b3017851924b1e7525dea.zip
Check exact values for specified cases
Inputs in `case_list` shouldn't hit xfails or increased ULP tolerance.
Ensure that overrides are skipped when testing against MPFR or a
specified value and that NaNs, if any, are checked bitwise.
-rw-r--r--library/compiler-builtins/libm/crates/libm-test/src/gen/case_list.rs10
-rw-r--r--library/compiler-builtins/libm/crates/libm-test/src/test_traits.rs14
2 files changed, 21 insertions, 3 deletions
diff --git a/library/compiler-builtins/libm/crates/libm-test/src/gen/case_list.rs b/library/compiler-builtins/libm/crates/libm-test/src/gen/case_list.rs
index 8c7a735fa70..7cb9897d8d2 100644
--- a/library/compiler-builtins/libm/crates/libm-test/src/gen/case_list.rs
+++ b/library/compiler-builtins/libm/crates/libm-test/src/gen/case_list.rs
@@ -579,8 +579,11 @@ fn rint_cases() -> Vec<TestCase<op::rint::Routine>> {
     TestCase::append_pairs(
         &mut v,
         &[
-            // Failure on i586
+            // Known failure on i586
+            #[cfg(not(x86_no_sse))]
             ((hf64!("-0x1.e3f13ff995ffcp+38"),), Some(hf64!("-0x1.e3f13ff994000p+38"))),
+            #[cfg(x86_no_sse)]
+            ((hf64!("-0x1.e3f13ff995ffcp+38"),), Some(hf64!("-0x1.e3f13ff998000p+38"))),
         ],
     );
     v
@@ -628,8 +631,11 @@ fn roundeven_cases() -> Vec<TestCase<op::roundeven::Routine>> {
     TestCase::append_pairs(
         &mut v,
         &[
-            // Failure on i586
+            // Known failure on i586
+            #[cfg(not(x86_no_sse))]
             ((hf64!("-0x1.e3f13ff995ffcp+38"),), Some(hf64!("-0x1.e3f13ff994000p+38"))),
+            #[cfg(x86_no_sse)]
+            ((hf64!("-0x1.e3f13ff995ffcp+38"),), Some(hf64!("-0x1.e3f13ff998000p+38"))),
         ],
     );
     v
diff --git a/library/compiler-builtins/libm/crates/libm-test/src/test_traits.rs b/library/compiler-builtins/libm/crates/libm-test/src/test_traits.rs
index 1bd5bce162b..bba1fca64e6 100644
--- a/library/compiler-builtins/libm/crates/libm-test/src/test_traits.rs
+++ b/library/compiler-builtins/libm/crates/libm-test/src/test_traits.rs
@@ -12,7 +12,9 @@ use anyhow::{Context, anyhow, bail, ensure};
 use libm::support::Hexf;
 
 use crate::precision::CheckAction;
-use crate::{CheckCtx, Float, Int, MaybeOverride, SpecialCase, TestResult};
+use crate::{
+    CheckBasis, CheckCtx, Float, GeneratorKind, Int, MaybeOverride, SpecialCase, TestResult,
+};
 
 /// Trait for calling a function with a tuple as arguments.
 ///
@@ -207,6 +209,8 @@ where
     SpecialCase: MaybeOverride<Input>,
 {
     let (result, xfail_msg) = match SpecialCase::check_int(input, actual, expected, ctx) {
+        // `require_biteq` forbids overrides.
+        _ if ctx.gen_kind == GeneratorKind::List => (actual == expected, None),
         CheckAction::AssertSuccess => (actual == expected, None),
         CheckAction::AssertFailure(msg) => (actual != expected, Some(msg)),
         CheckAction::Custom(res) => return res,
@@ -291,7 +295,12 @@ where
     let mut inner = || -> TestResult {
         let mut allowed_ulp = ctx.ulp;
 
+        // Forbid overrides if the items came from an explicit list, as long as we are checking
+        // against either MPFR or the result itself.
+        let require_biteq = ctx.gen_kind == GeneratorKind::List && ctx.basis != CheckBasis::Musl;
+
         match SpecialCase::check_float(input, actual, expected, ctx) {
+            _ if require_biteq => (),
             CheckAction::AssertSuccess => (),
             CheckAction::AssertFailure(msg) => assert_failure_msg = Some(msg),
             CheckAction::Custom(res) => return res,
@@ -301,6 +310,9 @@ where
 
         // Check when both are NaNs
         if actual.is_nan() && expected.is_nan() {
+            if require_biteq && ctx.basis == CheckBasis::None {
+                ensure!(actual.to_bits() == expected.to_bits(), "mismatched NaN bitpatterns");
+            }
             // By default, NaNs have nothing special to check.
             return Ok(());
         } else if actual.is_nan() || expected.is_nan() {