[libcxx-commits] [libcxx] r363740 - Disable the 'nextafter' portions of these tests on PPC when using 128-bit doubles because the 'nextafter' call doesn't work right. Reviewed as https://reviews.llvm.org/D62384. Thanks to Xing Xue for the patch, and Hubert for the explanation.

Marshall Clow via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jun 18 14:20:03 PDT 2019


Author: marshall
Date: Tue Jun 18 14:20:02 2019
New Revision: 363740

URL: http://llvm.org/viewvc/llvm-project?rev=363740&view=rev
Log:
Disable the 'nextafter' portions of these tests on PPC when using 128-bit doubles because the 'nextafter' call doesn't work right. Reviewed as https://reviews.llvm.org/D62384. Thanks to Xing Xue for the patch, and Hubert for the explanation.

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

Modified: libcxx/trunk/test/std/numerics/numeric.ops/numeric.ops.midpoint/midpoint.float.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numeric.ops/numeric.ops.midpoint/midpoint.float.pass.cpp?rev=363740&r1=363739&r2=363740&view=diff
==============================================================================
--- libcxx/trunk/test/std/numerics/numeric.ops/numeric.ops.midpoint/midpoint.float.pass.cpp (original)
+++ libcxx/trunk/test/std/numerics/numeric.ops/numeric.ops.midpoint/midpoint.float.pass.cpp Tue Jun 18 14:20:02 2019
@@ -92,25 +92,33 @@ void fp_test()
     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);
+#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);
+		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);
+    }
 }
 
 




More information about the libcxx-commits mailing list