[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
Fri May 24 06:09:18 PDT 2019
xingxue created this revision.
xingxue added reviewers: hubert.reinterpretcast, mclow.lists, sfertile, jasonliu.
xingxue added a project: libc++.
Herald added a reviewer: EricWF.
Herald added subscribers: libcxx-commits, jsji, ldionne, christof.
For 128 bit `long double` implemented as 2 `double`s on `PowerPC`, `nextafterl()` of `libm` gives imprecise results which fails the test that checks the `midpoint` of adjacent values. This patch skips the test for this particular case on `PowerPC`.
Repository:
rCXX libc++
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
@@ -14,6 +14,7 @@
//
#include <numeric>
+#include <iostream>
#include <cassert>
#include "test_macros.h"
@@ -81,25 +82,40 @@
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 __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.
+ bool skipTest = sizeof(T) == 16 ? true : false;
+#else
+ bool skipTest = false;
+#endif
+ if (!skipTest) {
+ // 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);
+ } else {
+ std::cerr
+ << "Skipped checking midpoint of adjacent values for PPC double-double."
+ << "\n";
+ }
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62384.201210.patch
Type: text/x-patch
Size: 2305 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20190524/1a5d4f44/attachment.bin>
More information about the libcxx-commits
mailing list