This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Adjust c-c++-common/opaque-vector.c testcase (PR c++/80459)


Hi!

The testcase attempts to use long double __attribute__((vector_size (16)))
vector and in addition to that uses __typeof((v<v)[0]).
The preconditions of that are not just that long double has size which is
power of 2 (e.g. satisfied on x86_64 for sizeof, but not really because
it is still actually just 80-bit), but also that the size must not be larger
than 16 (otherwise not even a single element would fit) and because v<v has
type of an integral vector, there also needs to be an integral type of that
size, which is not available e.g. on ILP32 targets when long double is
128-bit but there is no __int128_t.

Tested on x86_64-linux and i686-linux, ok for trunk?

2017-04-19  Jakub Jelinek  <jakub@redhat.com>

	PR c++/80459
	* c-c++-common/opaque-vector.c (SIZEOF_MAXINT): Define.
	(f): Don't test long double vectors if __SIZEOF_LONG_DOUBLE__
	is not power of 2, or is more than 16 or more than SIZEOF_MAXINT.

--- gcc/testsuite/c-c++-common/opaque-vector.c.jj	2013-10-21 09:00:50.000000000 +0200
+++ gcc/testsuite/c-c++-common/opaque-vector.c	2017-04-19 10:24:19.154548627 +0200
@@ -5,6 +5,11 @@
 #define T_TEST(TYPE)
 #endif
 #define T(TYPE) B_TEST(TYPE) T_TEST(TYPE)
+#ifdef __SIZEOF_INT128__
+#define SIZEOF_MAXINT __SIZEOF_INT128__
+#else
+#define SIZEOF_MAXINT __SIZEOF_LONG_LONG__
+#endif
 
 void f ()
 {
@@ -15,8 +20,13 @@ void f ()
 
   T_TEST(float)
   T_TEST(double)
-  /* Avoid trouble with non-power-of-two sizes.  */
-#if !defined(__i386__) && !defined(__x86_64__) && !defined(__m68k__) && !defined(__ia64__) && !defined(__hppa__)
+  /* Avoid trouble with non-power-of-two sizes.
+     Also avoid trouble with long double larger than integral types.  */
+#if !defined(__i386__) && !defined(__x86_64__) && !defined(__m68k__) \
+    && !defined(__ia64__) && !defined(__hppa__) \
+    && (__SIZEOF_LONG_DOUBLE__ & (__SIZEOF_LONG_DOUBLE__ - 1)) == 0 \
+    && __SIZEOF_LONG_DOUBLE__ <= 16 \
+    && __SIZEOF_LONG_DOUBLE__ <= SIZEOF_MAXINT
   T_TEST(long double)
 #endif
 }

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]