[libcxx-commits] [PATCH] D111671: [libcxx] [test] Generalize the conditions for testing bitcasts between long double, double and int128

Martin Storsjö via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Oct 12 13:05:01 PDT 2021


mstorsjo created this revision.
mstorsjo added reviewers: ldionne, Quuxplusone.
Herald added a subscriber: kristof.beyls.
mstorsjo requested review of this revision.
Herald added a project: libc++.
Herald added a reviewer: libc++.

MSVC targets also have a 64 bit long double, as do MinGW targets on ARM.
This hasn't been noticed in CI because the MSVC configurations there run
with _LIBCPP_HAS_NO_INT128 defined.

This avoids assuming that either __int128_t or double is equal in size to
long double. i386 MinGW targets have sizeof(long double) == 10, which
doesn't match any of the tested types.

Unfortunately, this relies on using nonstandard __SIZEOF_*__ defines.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111671

Files:
  libcxx/test/std/numerics/bit/bit.cast/bit_cast.pass.cpp


Index: libcxx/test/std/numerics/bit/bit.cast/bit_cast.pass.cpp
===================================================================
--- libcxx/test/std/numerics/bit/bit.cast/bit_cast.pass.cpp
+++ libcxx/test/std/numerics/bit/bit.cast/bit_cast.pass.cpp
@@ -227,18 +227,14 @@
         test_roundtrip_through_nested_T<false>(i);
         test_roundtrip_through_buffer<false>(i);
 
-        // On arm64 on Apple platforms, long double is just double, so we don't
-        // test against int128, but instead against double itself. Otherwise,
-        // we test against int128 if we have those types available.
-#if defined(__aarch64__) && defined(__APPLE__)
-#   define LONG_DOUBLE_IS_DOUBLE
-#endif
-
-#if defined(LONG_DOUBLE_IS_DOUBLE)
+#if defined(__SIZEOF_LONG_DOUBLE__) && defined(__SIZEOF_DOUBLE__) && __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__
         test_roundtrip_through<double, false>(i);
-#elif !defined(_LIBCPP_HAS_NO_INT128)
+#endif
+#if !defined(_LIBCPP_HAS_NO_INT128)
+#if defined(__SIZEOF_LONG_DOUBLE__) && defined(__SIZEOF_INT128__) && __SIZEOF_LONG_DOUBLE__ == __SIZEOF_INT128__
         test_roundtrip_through<__int128_t, false>(i);
         test_roundtrip_through<__uint128_t, false>(i);
+#endif
 #endif
     }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111671.379157.patch
Type: text/x-patch
Size: 1233 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20211012/cd1cd6fe/attachment.bin>


More information about the libcxx-commits mailing list