[libcxx-commits] [PATCH] D62384: [libcxx][tests]Skip checking midpoint of adjacent values for PPC double-double

Xing Xue via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Jun 6 08:30:02 PDT 2019


xingxue updated this revision to Diff 203372.
xingxue added a comment.

Addressed comments:

- Skip the test of midpoint of adjacent values for `PPC` double-double based on compile-time checking;
- Use `#if defined(__PPC__)` instead of `#if __PPC__` ;
- Removed output to `std::cerr`.


Repository:
  rCXX libc++

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62384/new/

https://reviews.llvm.org/D62384

Files:
  libcxx/test/std/numerics/numeric.ops/numeric.ops.midpoint/midpoint.float.pass.cpp


Index: libcxx/test/std/numerics/numeric.ops/numeric.ops.midpoint/midpoint.float.pass.cpp
===================================================================
--- libcxx/test/std/numerics/numeric.ops/numeric.ops.midpoint/midpoint.float.pass.cpp
+++ libcxx/test/std/numerics/numeric.ops/numeric.ops.midpoint/midpoint.float.pass.cpp
@@ -81,25 +81,34 @@
     assert(d0 < d1);  // sanity checking
     assert(d1 < d2);  // sanity checking
 
-//  Since there's nothing in between, the midpoint has to be one or the other
-    T res;
-    res = std::midpoint(d0, d1);
-    assert(res == d0 || res == d1);
-    assert(d0 <= res);
-    assert(res <= d1);
-    res = std::midpoint(d1, d0);
-    assert(res == d0 || res == d1);
-    assert(d0 <= res);
-    assert(res <= d1);
-
-    res = std::midpoint(d1, d2);
-    assert(res == d1 || res == d2);
-    assert(d1 <= res);
-    assert(res <= d2);
-    res = std::midpoint(d2, d1);
-    assert(res == d1 || res == d2);
-    assert(d1 <= res);
-    assert(res <= d2);
+#if defined(__PPC__) && __LONG_DOUBLE_128__ && !__LONG_DOUBLE_IEEE128__
+    // For 128 bit long double implemented as 2 doubles on PowerPC,
+    // nextafterl() of libm gives imprecise results which fails the
+    // midpoint() tests below. So skip the test for this case.
+    if constexpr (sizeof(T) != 16)
+#endif
+    {
+        // Since there's nothing in between, the midpoint has to be one or
+        // the other.
+        T res;
+        res = std::midpoint(d0, d1);
+        assert(res == d0 || res == d1);
+        assert(d0 <= res);
+        assert(res <= d1);
+        res = std::midpoint(d1, d0);
+        assert(res == d0 || res == d1);
+        assert(d0 <= res);
+        assert(res <= d1);
+
+        res = std::midpoint(d1, d2);
+        assert(res == d1 || res == d2);
+        assert(d1 <= res);
+        assert(res <= d2);
+        res = std::midpoint(d2, d1);
+        assert(res == d1 || res == d2);
+        assert(d1 <= res);
+        assert(res <= d2);
+    }
 }
 
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62384.203372.patch
Type: text/x-patch
Size: 2001 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20190606/f19425d7/attachment-0001.bin>


More information about the libcxx-commits mailing list