This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[AVX] Add AVX runtime check
- From: "H.J. Lu" <hongjiu dot lu at intel dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Joey Ye <joey dot ye at intel dot com>, Xuepeng Guo <xuepeng dot guo at intel dot com>
- Date: Mon, 18 Aug 2008 15:29:27 -0700
- Subject: [AVX] Add AVX runtime check
- Reply-to: "H.J. Lu" <hjl dot tools at gmail dot com>
Hi,
I am checking the following patch into AVX branch to add some AVX
runtime check.
H.J.
---
2008-08-18 H.J. Lu <hongjiu.lu@intel.com>
* gcc.target/i386/avx-check.h: New.
* gcc.target/i386/m256-check.h: Likewise.
* gcc.target/i386/m256-1.c: Likewise.
* gcc.target/i386/m256-2.c: Likewise.
* gcc.target/i386/vararg-3.c: Likewise.
* gcc.target/i386/vararg-4.c: Likewise.
* gcc.target/i386/vararg-5.c: Likewise.
* gcc.target/i386/vararg-6.c: Likewise.
* gcc.target/i386/vararg-7.c: Likewise.
* gcc.target/i386/vararg-8.c: Likewise.
* gcc.target/i386/vararg-9.c: Likewise.
* gcc.target/i386/vararg-10.c: Likewise.
Index: gcc.target/i386/vararg-4.c
===================================================================
--- gcc.target/i386/vararg-4.c (revision 0)
+++ gcc.target/i386/vararg-4.c (revision 0)
@@ -0,0 +1,92 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -msse2" } */
+
+#include <stdarg.h>
+#include <assert.h>
+
+#include "sse2-check.h"
+
+__m128 n1 = { -283.3, -23.3, 213.4, 1119.03 };
+__m128d n2 = { -93.83, 893.318 };
+__m128i n3 = { 893, -3180 } ;
+int n4 = 324;
+double n5 = 103.3;
+__m128i n6 = { -123, 2 };
+__m128d n7 = { -91.387, -8193.518 };
+__m128 n8 = { -123.3, 2.3, 3.4, -10.03 };
+__m128i n9 = { 1233, -100 };
+int n10 = 407;
+double n11 = 304.9;
+__m128i n12 = { 233, -110 };
+__m128i n13 = { -393, -180 };
+__m128d n14 = { 73.0, 63.18 };
+__m128 n15 = { -183.3, 22.3, 13.4, -19.03 };
+
+__m128 e1;
+__m128d e2;
+__m128i e3;
+int e4;
+double e5;
+__m128i e6;
+__m128d e7;
+__m128 e8;
+__m128i e9;
+int e10;
+double e11;
+__m128i e12;
+__m128i e13;
+__m128d e14;
+__m128 e15;
+
+static void
+__attribute__((noinline))
+foo (va_list va_arglist)
+{
+ e4 = va_arg (va_arglist, int);
+ e5 = va_arg (va_arglist, double);
+ e6 = va_arg (va_arglist, __m128i);
+ e7 = va_arg (va_arglist, __m128d);
+ e8 = va_arg (va_arglist, __m128);
+ e9 = va_arg (va_arglist, __m128i);
+ e10 = va_arg (va_arglist, int);
+ e11 = va_arg (va_arglist, double);
+ e12 = va_arg (va_arglist, __m128i);
+ e13 = va_arg (va_arglist, __m128i);
+ e14 = va_arg (va_arglist, __m128d);
+ e15 = va_arg (va_arglist, __m128);
+}
+
+static void
+__attribute__((noinline))
+test (__m128 a1, __m128d a2, __m128i a3, ...)
+{
+ va_list va_arglist;
+
+ e1 = a1;
+ e2 = a2;
+ e3 = a3;
+ va_start (va_arglist, a3);
+ foo (va_arglist);
+ va_end (va_arglist);
+}
+
+static void
+sse2_test (void)
+{
+ test (n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15);
+ assert (__builtin_memcmp (&e1, &n1, sizeof (e1)) == 0);
+ assert (__builtin_memcmp (&e2, &n2, sizeof (e2)) == 0);
+ assert (__builtin_memcmp (&e3, &n3, sizeof (e3)) == 0);
+ assert (n4 == e4);
+ assert (n5 == e5);
+ assert (__builtin_memcmp (&e6, &n6, sizeof (e6)) == 0);
+ assert (__builtin_memcmp (&e7, &n7, sizeof (e7)) == 0);
+ assert (__builtin_memcmp (&e8, &n8, sizeof (e8)) == 0);
+ assert (__builtin_memcmp (&e9, &n9, sizeof (e9)) == 0);
+ assert (n10 == e10);
+ assert (n11 == e11);
+ assert (__builtin_memcmp (&e12, &n12, sizeof (e12)) == 0);
+ assert (__builtin_memcmp (&e13, &n13, sizeof (e13)) == 0);
+ assert (__builtin_memcmp (&e14, &n14, sizeof (e14)) == 0);
+ assert (__builtin_memcmp (&e15, &n15, sizeof (e15)) == 0);
+}
Index: gcc.target/i386/vararg-5.c
===================================================================
--- gcc.target/i386/vararg-5.c (revision 0)
+++ gcc.target/i386/vararg-5.c (revision 0)
@@ -0,0 +1,99 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx } */
+/* { dg-options "-mavx" } */
+
+#include <stdarg.h>
+#include <assert.h>
+
+#include "avx-check.h"
+
+__m128 n1 = { -283.3, -23.3, 213.4, 1119.03 };
+__m256d n2 = { -93.83, 893.318, 3994.3, -39484.0 };
+__m128i n3 = { 893, -3180 } ;
+int n4 = 324;
+double n5 = 103.3;
+__m128i n6 = { -123, 2 };
+__m128d n7 = { -91.387, -8193.518 };
+__m256d n8 = { -123.3, 2.3, 3.4, -10.03 };
+__m128 n9 = { -123.3, 2.3, 3.4, -10.03 };
+__m128i n10 = { 1233, -100 };
+int n11 = 407;
+double n12 = 304.9;
+__m128i n13 = { 233, -110 };
+__m256i n14 = { -1233, 23, 34, -1003 };
+__m128i n15 = { -393, -180 };
+__m128d n16 = { 73.0, 63.18 };
+__m256 n17 = { -183.3, -22.3, 13.9, -119.3, 483.1, 122.3, -33.4, -9.37 };
+__m128 n18 = { -183.3, 22.3, 13.4, -19.03 };
+
+__m128 e1;
+__m256d e2;
+__m128i e3;
+int e4;
+double e5;
+__m128i e6;
+__m128d e7;
+__m256d e8;
+__m128 e9;
+__m128i e10;
+int e11;
+double e12;
+__m128i e13;
+__m256i e14;
+__m128i e15;
+__m128d e16;
+__m256 e17;
+__m128 e18;
+
+static void
+__attribute__((noinline))
+test (__m128 a1, __m256d a2, __m128i a3, ...)
+{
+ va_list va_arglist;
+
+ e1 = a1;
+ e2 = a2;
+ e3 = a3;
+ va_start (va_arglist, a3);
+ e4 = va_arg (va_arglist, int);
+ e5 = va_arg (va_arglist, double);
+ e6 = va_arg (va_arglist, __m128i);
+ e7 = va_arg (va_arglist, __m128d);
+ e8 = va_arg (va_arglist, __m256d);
+ e9 = va_arg (va_arglist, __m128);
+ e10 = va_arg (va_arglist, __m128i);
+ e11 = va_arg (va_arglist, int);
+ e12 = va_arg (va_arglist, double);
+ e13 = va_arg (va_arglist, __m128i);
+ e14 = va_arg (va_arglist, __m256i);
+ e15 = va_arg (va_arglist, __m128i);
+ e16 = va_arg (va_arglist, __m128d);
+ e17 = va_arg (va_arglist, __m256);
+ e18 = va_arg (va_arglist, __m128);
+ va_end (va_arglist);
+}
+
+static void
+avx_test (void)
+{
+ test (n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12,
+ n13, n14, n15, n16, n17, n18);
+ assert (__builtin_memcmp (&e1, &n1, sizeof (e1)) == 0);
+ assert (__builtin_memcmp (&e2, &n2, sizeof (e2)) == 0);
+ assert (__builtin_memcmp (&e3, &n3, sizeof (e3)) == 0);
+ assert (n4 == e4);
+ assert (n5 == e5);
+ assert (__builtin_memcmp (&e6, &n6, sizeof (e6)) == 0);
+ assert (__builtin_memcmp (&e7, &n7, sizeof (e7)) == 0);
+ assert (__builtin_memcmp (&e8, &n8, sizeof (e8)) == 0);
+ assert (__builtin_memcmp (&e9, &n9, sizeof (e9)) == 0);
+ assert (__builtin_memcmp (&e10, &n10, sizeof (e10)) == 0);
+ assert (n11 == e11);
+ assert (n12 == e12);
+ assert (__builtin_memcmp (&e13, &n13, sizeof (e13)) == 0);
+ assert (__builtin_memcmp (&e14, &n14, sizeof (e14)) == 0);
+ assert (__builtin_memcmp (&e15, &n15, sizeof (e15)) == 0);
+ assert (__builtin_memcmp (&e16, &n16, sizeof (e16)) == 0);
+ assert (__builtin_memcmp (&e17, &n17, sizeof (e17)) == 0);
+ assert (__builtin_memcmp (&e18, &n18, sizeof (e18)) == 0);
+}
Index: gcc.target/i386/m256-check.h
===================================================================
--- gcc.target/i386/m256-check.h (revision 0)
+++ gcc.target/i386/m256-check.h (revision 0)
@@ -0,0 +1,196 @@
+#include <gmmintrin.h>
+
+#ifdef DEBUG
+#include <stdio.h>
+#endif
+
+#ifndef max
+#define max(a, b) (((a) > (b)) ? (a):(b))
+#endif
+#ifndef min
+#define min(a, b) (((a) < (b)) ? (a):(b))
+#endif
+
+typedef union
+{
+ __m128i x;
+ char a[16];
+} union128i_b;
+
+typedef union
+{
+ __m128i x;
+ short a[8];
+} union128i_w;
+
+typedef union
+{
+ __m128i x;
+ int a[4];
+} union128i_d;
+
+typedef union
+{
+ __m128i x;
+ long long a[2];
+} union128i_q;
+
+typedef union
+{
+ __m128 x;
+ float a[4];
+} union128;
+
+typedef union
+{
+ __m128d x;
+ double a[2];
+} union128d;
+
+typedef union
+{
+ __m256i x;
+ char a[32];
+} union256i_b;
+
+typedef union
+{
+ __m256i x;
+ short a[16];
+} union256i_w;
+
+typedef union
+{
+ __m256i x;
+ int a[8];
+} union256i_d;
+
+typedef union
+{
+ __m256i x;
+ long long a[4];
+} union256i_q;
+
+typedef union
+{
+ __m256 x;
+ float a[8];
+} union256;
+
+typedef union
+{
+ __m256d x;
+ double a[4];
+} union256d;
+
+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(A) (sizeof (A) / sizeof ((A)[0]))
+#endif
+
+#ifdef DEBUG
+#define PRINTF printf
+#else
+#define PRINTF(...)
+#endif
+
+#define CHECK_EXP(UINON_TYPE, VALUE_TYPE, FMT) \
+static int \
+__attribute__((noinline, unused)) \
+check_##UINON_TYPE (UINON_TYPE u, const VALUE_TYPE *v) \
+{ \
+ int i; \
+ int err = 0; \
+ \
+ for (i = 0; i < ARRAY_SIZE (u.a); i++) \
+ if (u.a[i] != v[i]) \
+ { \
+ err++; \
+ PRINTF ("%i: " FMT " != " FMT "\n", \
+ i, v[i], u.a[i]); \
+ } \
+ return err; \
+}
+
+CHECK_EXP (union128i_b, char, "%d")
+CHECK_EXP (union128i_w, short, "%d")
+CHECK_EXP (union128i_d, int, "0x%x")
+CHECK_EXP (union128i_q, long long, "0x%llx")
+CHECK_EXP (union128, float, "%f")
+CHECK_EXP (union128d, double, "%f")
+
+CHECK_EXP (union256i_b, char, "%d")
+CHECK_EXP (union256i_w, short, "%d")
+CHECK_EXP (union256i_d, int, "0x%x")
+CHECK_EXP (union256i_q, long long, "0x%llx")
+CHECK_EXP (union256, float, "%f")
+CHECK_EXP (union256d, double, "%f")
+
+#define CHECK_FP_EXP(UINON_TYPE, VALUE_TYPE, ESP, FMT) \
+static int \
+__attribute__((noinline, unused)) \
+check_fp_##UINON_TYPE (UINON_TYPE u, const VALUE_TYPE *v) \
+{ \
+ int i; \
+ int err = 0; \
+ \
+ for (i = 0; i < ARRAY_SIZE (u.a); i++) \
+ if (u.a[i] > (v[i] + (ESP)) || u.a[i] < (v[i] - (ESP))) \
+ { \
+ err++; \
+ PRINTF ("%i: " FMT " != " FMT "\n", \
+ i, v[i], u.a[i]); \
+ } \
+ return err; \
+}
+
+#define ESP_FLOAT 0.000001
+#define ESP_DOUBLE 0.000001
+
+CHECK_FP_EXP (union128, float, ESP_FLOAT, "%f")
+CHECK_FP_EXP (union128d, double, ESP_DOUBLE, "%f")
+
+CHECK_FP_EXP (union256, float, ESP_FLOAT, "%f")
+CHECK_FP_EXP (union256d, double, ESP_DOUBLE, "%f")
+
+#define CHECK_ARRAY(ARRAY, TYPE, FMT) \
+static int \
+__attribute__((noinline, unused)) \
+checkV##ARRAY (const TYPE *v, const TYPE *e, int n) \
+{ \
+ int i; \
+ int err = 0; \
+ \
+ for (i = 0; i < n; i++) \
+ if (v[i] != e[i]) \
+ { \
+ err++; \
+ PRINTF ("%i: " FMT " != " FMT "\n", \
+ i, v[i], e[i]); \
+ } \
+ return err; \
+}
+
+CHECK_ARRAY(i, int, "0x%x")
+CHECK_ARRAY(l, long long, "0x%llx")
+
+#define CHECK_FP_ARRAY(ARRAY, TYPE, ESP, FMT) \
+static int \
+__attribute__((noinline, unused)) \
+checkV##ARRAY (const TYPE *v, const TYPE *e, int n) \
+{ \
+ int i; \
+ int err = 0; \
+ \
+ for (i = 0; i < n; i++) \
+ if (v[i] > (e[i] + (ESP)) || v[i] < (e[i] - (ESP))) \
+ if (e[i] != v[i]) \
+ { \
+ err++; \
+ PRINTF ("%i: " FMT " != " FMT "\n", \
+ i, v[i], e[i]); \
+ } \
+ return err; \
+}
+
+CHECK_FP_ARRAY (d, double, ESP_DOUBLE, "%f")
+CHECK_FP_ARRAY (f, float, ESP_FLOAT, "%f")
Index: gcc.target/i386/vararg-6.c
===================================================================
--- gcc.target/i386/vararg-6.c (revision 0)
+++ gcc.target/i386/vararg-6.c (revision 0)
@@ -0,0 +1,107 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx } */
+/* { dg-options "-mavx" } */
+
+#include <stdarg.h>
+#include <assert.h>
+
+#include "avx-check.h"
+
+__m128 n1 = { -283.3, -23.3, 213.4, 1119.03 };
+__m256d n2 = { -93.83, 893.318, 3994.3, -39484.0 };
+__m128i n3 = { 893, -3180 } ;
+int n4 = 324;
+double n5 = 103.3;
+__m128i n6 = { -123, 2 };
+__m128d n7 = { -91.387, -8193.518 };
+__m256d n8 = { -123.3, 2.3, 3.4, -10.03 };
+__m128 n9 = { -123.3, 2.3, 3.4, -10.03 };
+__m128i n10 = { 1233, -100 };
+int n11 = 407;
+double n12 = 304.9;
+__m128i n13 = { 233, -110 };
+__m256i n14 = { -1233, 23, 34, -1003 };
+__m128i n15 = { -393, -180 };
+__m128d n16 = { 73.0, 63.18 };
+__m256 n17 = { -183.3, -22.3, 13.9, -119.3, 483.1, 122.3, -33.4, -9.37 };
+__m128 n18 = { -183.3, 22.3, 13.4, -19.03 };
+
+__m128 e1;
+__m256d e2;
+__m128i e3;
+int e4;
+double e5;
+__m128i e6;
+__m128d e7;
+__m256d e8;
+__m128 e9;
+__m128i e10;
+int e11;
+double e12;
+__m128i e13;
+__m256i e14;
+__m128i e15;
+__m128d e16;
+__m256 e17;
+__m128 e18;
+
+static void
+__attribute__((noinline))
+foo (va_list va_arglist)
+{
+ e4 = va_arg (va_arglist, int);
+ e5 = va_arg (va_arglist, double);
+ e6 = va_arg (va_arglist, __m128i);
+ e7 = va_arg (va_arglist, __m128d);
+ e8 = va_arg (va_arglist, __m256d);
+ e9 = va_arg (va_arglist, __m128);
+ e10 = va_arg (va_arglist, __m128i);
+ e11 = va_arg (va_arglist, int);
+ e12 = va_arg (va_arglist, double);
+ e13 = va_arg (va_arglist, __m128i);
+ e14 = va_arg (va_arglist, __m256i);
+ e15 = va_arg (va_arglist, __m128i);
+ e16 = va_arg (va_arglist, __m128d);
+ e17 = va_arg (va_arglist, __m256);
+ e18 = va_arg (va_arglist, __m128);
+ va_end (va_arglist);
+}
+
+static void
+__attribute__((noinline))
+test (__m128 a1, __m256d a2, __m128i a3, ...)
+{
+ va_list va_arglist;
+
+ e1 = a1;
+ e2 = a2;
+ e3 = a3;
+ va_start (va_arglist, a3);
+ foo (va_arglist);
+ va_end (va_arglist);
+}
+
+static void
+avx_test (void)
+{
+ test (n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12,
+ n13, n14, n15, n16, n17, n18);
+ assert (__builtin_memcmp (&e1, &n1, sizeof (e1)) == 0);
+ assert (__builtin_memcmp (&e2, &n2, sizeof (e2)) == 0);
+ assert (__builtin_memcmp (&e3, &n3, sizeof (e3)) == 0);
+ assert (n4 == e4);
+ assert (n5 == e5);
+ assert (__builtin_memcmp (&e6, &n6, sizeof (e6)) == 0);
+ assert (__builtin_memcmp (&e7, &n7, sizeof (e7)) == 0);
+ assert (__builtin_memcmp (&e8, &n8, sizeof (e8)) == 0);
+ assert (__builtin_memcmp (&e9, &n9, sizeof (e9)) == 0);
+ assert (__builtin_memcmp (&e10, &n10, sizeof (e10)) == 0);
+ assert (n11 == e11);
+ assert (n12 == e12);
+ assert (__builtin_memcmp (&e13, &n13, sizeof (e13)) == 0);
+ assert (__builtin_memcmp (&e14, &n14, sizeof (e14)) == 0);
+ assert (__builtin_memcmp (&e15, &n15, sizeof (e15)) == 0);
+ assert (__builtin_memcmp (&e16, &n16, sizeof (e16)) == 0);
+ assert (__builtin_memcmp (&e17, &n17, sizeof (e17)) == 0);
+ assert (__builtin_memcmp (&e18, &n18, sizeof (e18)) == 0);
+}
Index: gcc.target/i386/avx-check.h
===================================================================
--- gcc.target/i386/avx-check.h (revision 0)
+++ gcc.target/i386/avx-check.h (revision 0)
@@ -0,0 +1,29 @@
+#include <stdlib.h>
+#include "cpuid.h"
+#include "m256-check.h"
+
+static void avx_test (void);
+
+int
+main ()
+{
+ unsigned int eax, ebx, ecx, edx;
+
+ if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx))
+ return 0;
+
+ /* Run AVX test only if host has AVX support. */
+ if (ecx & bit_AVX)
+ {
+ avx_test ();
+#ifdef DEBUG
+ printf ("PASSED\n");
+#endif
+ }
+#ifdef DEBUG
+ else
+ printf ("SKIPPED\n");
+#endif
+
+ return 0;
+}
Index: gcc.target/i386/vararg-7.c
===================================================================
--- gcc.target/i386/vararg-7.c (revision 0)
+++ gcc.target/i386/vararg-7.c (revision 0)
@@ -0,0 +1,90 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -msse2" } */
+
+#include <stdarg.h>
+#include <assert.h>
+
+#include "sse2-check.h"
+
+struct m128
+{
+ __m128 v;
+};
+
+struct m128 n1 = { { -283.3, -23.3, 213.4, 1119.03 } };
+__m128d n2 = { -93.83, 893.318 };
+__m128i n3 = { 893, -3180 } ;
+int n4 = 324;
+double n5 = 103.3;
+__m128i n6 = { -123, 2 };
+__m128d n7 = { -91.387, -8193.518 };
+struct m128 n8 = { { -123.3, 2.3, 3.4, -10.03 } };
+__m128i n9 = { 1233, -100 };
+int n10 = 407;
+double n11 = 304.9;
+__m128i n12 = { 233, -110 };
+__m128i n13 = { -393, -180 };
+__m128d n14 = { 73.0, 63.18 };
+struct m128 n15 = { { -183.3, 22.3, 13.4, -19.03 } };
+
+struct m128 e1;
+__m128d e2;
+__m128i e3;
+int e4;
+double e5;
+__m128i e6;
+__m128d e7;
+struct m128 e8;
+__m128i e9;
+int e10;
+double e11;
+__m128i e12;
+__m128i e13;
+__m128d e14;
+struct m128 e15;
+
+static void
+__attribute__((noinline))
+test (struct m128 a1, __m128d a2, __m128i a3, ...)
+{
+ va_list va_arglist;
+
+ e1 = a1;
+ e2 = a2;
+ e3 = a3;
+ va_start (va_arglist, a3);
+ e4 = va_arg (va_arglist, int);
+ e5 = va_arg (va_arglist, double);
+ e6 = va_arg (va_arglist, __m128i);
+ e7 = va_arg (va_arglist, __m128d);
+ e8 = va_arg (va_arglist, struct m128);
+ e9 = va_arg (va_arglist, __m128i);
+ e10 = va_arg (va_arglist, int);
+ e11 = va_arg (va_arglist, double);
+ e12 = va_arg (va_arglist, __m128i);
+ e13 = va_arg (va_arglist, __m128i);
+ e14 = va_arg (va_arglist, __m128d);
+ e15 = va_arg (va_arglist, struct m128);
+ va_end (va_arglist);
+}
+
+static void
+sse2_test (void)
+{
+ test (n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15);
+ assert (__builtin_memcmp (&e1, &n1, sizeof (e1)) == 0);
+ assert (__builtin_memcmp (&e2, &n2, sizeof (e2)) == 0);
+ assert (__builtin_memcmp (&e3, &n3, sizeof (e3)) == 0);
+ assert (n4 == e4);
+ assert (n5 == e5);
+ assert (__builtin_memcmp (&e6, &n6, sizeof (e6)) == 0);
+ assert (__builtin_memcmp (&e7, &n7, sizeof (e7)) == 0);
+ assert (__builtin_memcmp (&e8, &n8, sizeof (e8)) == 0);
+ assert (__builtin_memcmp (&e9, &n9, sizeof (e9)) == 0);
+ assert (n10 == e10);
+ assert (n11 == e11);
+ assert (__builtin_memcmp (&e12, &n12, sizeof (e12)) == 0);
+ assert (__builtin_memcmp (&e13, &n13, sizeof (e13)) == 0);
+ assert (__builtin_memcmp (&e14, &n14, sizeof (e14)) == 0);
+ assert (__builtin_memcmp (&e15, &n15, sizeof (e15)) == 0);
+}
Index: gcc.target/i386/vararg-8.c
===================================================================
--- gcc.target/i386/vararg-8.c (revision 0)
+++ gcc.target/i386/vararg-8.c (revision 0)
@@ -0,0 +1,97 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -msse2" } */
+
+#include <stdarg.h>
+#include <assert.h>
+
+#include "sse2-check.h"
+
+struct m128
+{
+ __m128 v;
+};
+
+struct m128 n1 = { { -283.3, -23.3, 213.4, 1119.03 } };
+__m128d n2 = { -93.83, 893.318 };
+__m128i n3 = { 893, -3180 } ;
+int n4 = 324;
+double n5 = 103.3;
+__m128i n6 = { -123, 2 };
+__m128d n7 = { -91.387, -8193.518 };
+struct m128 n8 = { { -123.3, 2.3, 3.4, -10.03 } };
+__m128i n9 = { 1233, -100 };
+int n10 = 407;
+double n11 = 304.9;
+__m128i n12 = { 233, -110 };
+__m128i n13 = { -393, -180 };
+__m128d n14 = { 73.0, 63.18 };
+struct m128 n15 = { { -183.3, 22.3, 13.4, -19.03 } };
+
+struct m128 e1;
+__m128d e2;
+__m128i e3;
+int e4;
+double e5;
+__m128i e6;
+__m128d e7;
+struct m128 e8;
+__m128i e9;
+int e10;
+double e11;
+__m128i e12;
+__m128i e13;
+__m128d e14;
+struct m128 e15;
+
+static void
+__attribute__((noinline))
+foo (va_list va_arglist)
+{
+ e4 = va_arg (va_arglist, int);
+ e5 = va_arg (va_arglist, double);
+ e6 = va_arg (va_arglist, __m128i);
+ e7 = va_arg (va_arglist, __m128d);
+ e8 = va_arg (va_arglist, struct m128);
+ e9 = va_arg (va_arglist, __m128i);
+ e10 = va_arg (va_arglist, int);
+ e11 = va_arg (va_arglist, double);
+ e12 = va_arg (va_arglist, __m128i);
+ e13 = va_arg (va_arglist, __m128i);
+ e14 = va_arg (va_arglist, __m128d);
+ e15 = va_arg (va_arglist, struct m128);
+}
+
+static void
+__attribute__((noinline))
+test (struct m128 a1, __m128d a2, __m128i a3, ...)
+{
+ va_list va_arglist;
+
+ e1 = a1;
+ e2 = a2;
+ e3 = a3;
+ va_start (va_arglist, a3);
+ foo (va_arglist);
+ va_end (va_arglist);
+}
+
+static void
+sse2_test (void)
+{
+ test (n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15);
+ assert (__builtin_memcmp (&e1, &n1, sizeof (e1)) == 0);
+ assert (__builtin_memcmp (&e2, &n2, sizeof (e2)) == 0);
+ assert (__builtin_memcmp (&e3, &n3, sizeof (e3)) == 0);
+ assert (n4 == e4);
+ assert (n5 == e5);
+ assert (__builtin_memcmp (&e6, &n6, sizeof (e6)) == 0);
+ assert (__builtin_memcmp (&e7, &n7, sizeof (e7)) == 0);
+ assert (__builtin_memcmp (&e8, &n8, sizeof (e8)) == 0);
+ assert (__builtin_memcmp (&e9, &n9, sizeof (e9)) == 0);
+ assert (n10 == e10);
+ assert (n11 == e11);
+ assert (__builtin_memcmp (&e12, &n12, sizeof (e12)) == 0);
+ assert (__builtin_memcmp (&e13, &n13, sizeof (e13)) == 0);
+ assert (__builtin_memcmp (&e14, &n14, sizeof (e14)) == 0);
+ assert (__builtin_memcmp (&e15, &n15, sizeof (e15)) == 0);
+}
Index: gcc.target/i386/vararg-9.c
===================================================================
--- gcc.target/i386/vararg-9.c (revision 0)
+++ gcc.target/i386/vararg-9.c (revision 0)
@@ -0,0 +1,104 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx } */
+/* { dg-options "-mavx" } */
+
+#include <stdarg.h>
+#include <assert.h>
+
+#include "avx-check.h"
+
+struct m256d
+{
+ __m256d v;
+};
+
+__m128 n1 = { -283.3, -23.3, 213.4, 1119.03 };
+struct m256d n2 = { { -93.83, 893.318, 3994.3, -39484.0 } };
+__m128i n3 = { 893, -3180 } ;
+int n4 = 324;
+double n5 = 103.3;
+__m128i n6 = { -123, 2 };
+__m128d n7 = { -91.387, -8193.518 };
+struct m256d n8 = { { -123.3, 2.3, 3.4, -10.03 } };
+__m128 n9 = { -123.3, 2.3, 3.4, -10.03 };
+__m128i n10 = { 1233, -100 };
+int n11 = 407;
+double n12 = 304.9;
+__m128i n13 = { 233, -110 };
+__m256i n14 = { -1233, 23, 34, -1003 };
+__m128i n15 = { -393, -180 };
+__m128d n16 = { 73.0, 63.18 };
+__m256 n17 = { -183.3, -22.3, 13.9, -119.3, 483.1, 122.3, -33.4, -9.37 };
+__m128 n18 = { -183.3, 22.3, 13.4, -19.03 };
+
+__m128 e1;
+struct m256d e2;
+__m128i e3;
+int e4;
+double e5;
+__m128i e6;
+__m128d e7;
+struct m256d e8;
+__m128 e9;
+__m128i e10;
+int e11;
+double e12;
+__m128i e13;
+__m256i e14;
+__m128i e15;
+__m128d e16;
+__m256 e17;
+__m128 e18;
+
+static void
+__attribute__((noinline))
+test (__m128 a1, struct m256d a2, __m128i a3, ...)
+{
+ va_list va_arglist;
+
+ e1 = a1;
+ e2 = a2;
+ e3 = a3;
+ va_start (va_arglist, a3);
+ e4 = va_arg (va_arglist, int);
+ e5 = va_arg (va_arglist, double);
+ e6 = va_arg (va_arglist, __m128i);
+ e7 = va_arg (va_arglist, __m128d);
+ e8 = va_arg (va_arglist, struct m256d);
+ e9 = va_arg (va_arglist, __m128);
+ e10 = va_arg (va_arglist, __m128i);
+ e11 = va_arg (va_arglist, int);
+ e12 = va_arg (va_arglist, double);
+ e13 = va_arg (va_arglist, __m128i);
+ e14 = va_arg (va_arglist, __m256i);
+ e15 = va_arg (va_arglist, __m128i);
+ e16 = va_arg (va_arglist, __m128d);
+ e17 = va_arg (va_arglist, __m256);
+ e18 = va_arg (va_arglist, __m128);
+ va_end (va_arglist);
+}
+
+static void
+avx_test (void)
+{
+ test (n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12,
+ n13, n14, n15, n16, n17, n18);
+ assert (__builtin_memcmp (&e1, &n1, sizeof (e1)) == 0);
+ assert (__builtin_memcmp (&e2, &n2, sizeof (e2)) == 0);
+ assert (__builtin_memcmp (&e3, &n3, sizeof (e3)) == 0);
+ assert (n4 == e4);
+ assert (n5 == e5);
+ assert (__builtin_memcmp (&e6, &n6, sizeof (e6)) == 0);
+ assert (__builtin_memcmp (&e7, &n7, sizeof (e7)) == 0);
+ assert (__builtin_memcmp (&e8, &n8, sizeof (e8)) == 0);
+ assert (__builtin_memcmp (&e9, &n9, sizeof (e9)) == 0);
+ assert (__builtin_memcmp (&e10, &n10, sizeof (e10)) == 0);
+ assert (n11 == e11);
+ assert (n12 == e12);
+ assert (__builtin_memcmp (&e13, &n13, sizeof (e13)) == 0);
+ assert (__builtin_memcmp (&e14, &n14, sizeof (e14)) == 0);
+ assert (__builtin_memcmp (&e15, &n15, sizeof (e15)) == 0);
+ assert (__builtin_memcmp (&e16, &n16, sizeof (e16)) == 0);
+ assert (__builtin_memcmp (&e17, &n17, sizeof (e17)) == 0);
+ assert (__builtin_memcmp (&e18, &n18, sizeof (e18)) == 0);
+}
Index: gcc.target/i386/m256-1.c
===================================================================
--- gcc.target/i386/m256-1.c (revision 0)
+++ gcc.target/i386/m256-1.c (revision 0)
@@ -0,0 +1,63 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx } */
+/* { dg-options "-mavx" } */
+
+#include <assert.h>
+#include "avx-check.h"
+
+__m128 n1 = { -283.3, -23.3, 213.4, 1119.03 };
+__m256d n2 = { -93.83, 893.318, 3884.34, -3134.3 };
+__m256i n3 = { 893, -3180, 3334, -3984 };
+int n4 = -30;
+double n5 = 40.3;
+__m128i n6 = { 8931, -13984 };
+__m128d n7 = { 1893.318, -31134.3 };
+__m256 n8 =
+{
+ -913.87, 8193.518, 312884.34, -9134.9,
+ -19093.83, 89312.318, 7884.84, -4134.3
+};
+__m128 n9 = { -1283.3, -213.3, 3213.4, 81119.03 };
+__m128i n10 = { 28131, -313684 };
+int n11 = 103;
+double n12 = -3004.3;
+__m256d n13 = { 913.73, -93.38, 84.34, -734.3 };
+__m128d n14 = { -73.378, 934.31 };
+__m256 n15 =
+{
+ 13.73, -8193.318, 384.74, 734.9,
+ 193.83, 312.78, 7884.34, -8134.3
+};
+__m128i n16 = { 831, -3849 };
+
+void
+__attribute__((noinline))
+m256_test (__m128 a1, __m256d a2, __m256i a3, int a4, double a5,
+ __m128i a6, __m128d a7, __m256 a8, __m128 a9, __m128i a10,
+ int a11, double a12, __m256d a13, __m128d a14, __m256 a15,
+ __m128i a16)
+{
+ assert (__builtin_memcmp (&a1, &n1, sizeof (a1)) == 0);
+ assert (__builtin_memcmp (&a2, &n2, sizeof (a2)) == 0);
+ assert (__builtin_memcmp (&a3, &n3, sizeof (a3)) == 0);
+ assert (a4 == n4);
+ assert (a5 == n5);
+ assert (__builtin_memcmp (&a6, &n6, sizeof (a6)) == 0);
+ assert (__builtin_memcmp (&a7, &n7, sizeof (a7)) == 0);
+ assert (__builtin_memcmp (&a8, &n8, sizeof (a8)) == 0);
+ assert (__builtin_memcmp (&a9, &n9, sizeof (a9)) == 0);
+ assert (__builtin_memcmp (&a10, &n10, sizeof (a10)) == 0);
+ assert (a11 == n11);
+ assert (a12 == n12);
+ assert (__builtin_memcmp (&a13, &n13, sizeof (a13)) == 0);
+ assert (__builtin_memcmp (&a14, &n14, sizeof (a14)) == 0);
+ assert (__builtin_memcmp (&a15, &n15, sizeof (a15)) == 0);
+ assert (__builtin_memcmp (&a16, &n16, sizeof (a16)) == 0);
+}
+
+static void
+avx_test (void)
+{
+ m256_test (n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12,
+ n13, n14, n15, n16);
+}
Index: gcc.target/i386/m256-2.c
===================================================================
--- gcc.target/i386/m256-2.c (revision 0)
+++ gcc.target/i386/m256-2.c (revision 0)
@@ -0,0 +1,73 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx } */
+/* { dg-options "-mavx" } */
+
+#include <assert.h>
+#include "avx-check.h"
+
+struct m128
+{
+ __m128 v;
+};
+
+struct m256d
+{
+ __m256d v;
+};
+
+struct m128 n1 = { { -283.3, -23.3, 213.4, 1119.03 } };
+struct m256d n2 = { { -93.83, 893.318, 3884.34, -3134.3 } };
+__m256i n3 = { 893, -3180, 3334, -3984 };
+int n4 = -30;
+double n5 = 40.3;
+__m128i n6 = { 8931, -13984 };
+__m128d n7 = { 1893.318, -31134.3 };
+__m256 n8 =
+{
+ -913.87, 8193.518, 312884.34, -9134.9,
+ -19093.83, 89312.318, 7884.84, -4134.3
+};
+__m128 n9 = { -1283.3, -213.3, 3213.4, 81119.03 };
+__m128i n10 = { 28131, -313684 };
+int n11 = 103;
+double n12 = -3004.3;
+struct m256d n13 = { { 913.73, -93.38, 84.34, -734.3 } };
+__m128d n14 = { -73.378, 934.31 };
+__m256 n15 =
+{
+ 13.73, -8193.318, 384.74, 734.9,
+ 193.83, 312.78, 7884.34, -8134.3
+};
+__m128i n16 = { 831, -3849 };
+
+void
+__attribute__((noinline))
+m256_test (struct m128 a1, struct m256d a2, __m256i a3, int a4, double a5,
+ __m128i a6, __m128d a7, __m256 a8, __m128 a9, __m128i a10,
+ int a11, double a12, struct m256d a13, __m128d a14, __m256 a15,
+ __m128i a16)
+{
+ assert (__builtin_memcmp (&a1, &n1, sizeof (a1)) == 0);
+ assert (__builtin_memcmp (&a2, &n2, sizeof (a2)) == 0);
+ assert (__builtin_memcmp (&a3, &n3, sizeof (a3)) == 0);
+ assert (a4 == n4);
+ assert (a5 == n5);
+ assert (__builtin_memcmp (&a6, &n6, sizeof (a6)) == 0);
+ assert (__builtin_memcmp (&a7, &n7, sizeof (a7)) == 0);
+ assert (__builtin_memcmp (&a8, &n8, sizeof (a8)) == 0);
+ assert (__builtin_memcmp (&a9, &n9, sizeof (a9)) == 0);
+ assert (__builtin_memcmp (&a10, &n10, sizeof (a10)) == 0);
+ assert (a11 == n11);
+ assert (a12 == n12);
+ assert (__builtin_memcmp (&a13, &n13, sizeof (a13)) == 0);
+ assert (__builtin_memcmp (&a14, &n14, sizeof (a14)) == 0);
+ assert (__builtin_memcmp (&a15, &n15, sizeof (a15)) == 0);
+ assert (__builtin_memcmp (&a16, &n16, sizeof (a16)) == 0);
+}
+
+static void
+avx_test (void)
+{
+ m256_test (n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12,
+ n13, n14, n15, n16);
+}
Index: gcc.target/i386/vararg-10.c
===================================================================
--- gcc.target/i386/vararg-10.c (revision 0)
+++ gcc.target/i386/vararg-10.c (revision 0)
@@ -0,0 +1,112 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx } */
+/* { dg-options "-mavx" } */
+
+#include <stdarg.h>
+#include <assert.h>
+
+#include "avx-check.h"
+
+struct m256d
+{
+ __m256d v;
+};
+
+__m128 n1 = { -283.3, -23.3, 213.4, 1119.03 };
+struct m256d n2 = { { -93.83, 893.318, 3994.3, -39484.0 } };
+__m128i n3 = { 893, -3180 } ;
+int n4 = 324;
+double n5 = 103.3;
+__m128i n6 = { -123, 2 };
+__m128d n7 = { -91.387, -8193.518 };
+struct m256d n8 = { { -123.3, 2.3, 3.4, -10.03 } };
+__m128 n9 = { -123.3, 2.3, 3.4, -10.03 };
+__m128i n10 = { 1233, -100 };
+int n11 = 407;
+double n12 = 304.9;
+__m128i n13 = { 233, -110 };
+__m256i n14 = { -1233, 23, 34, -1003 };
+__m128i n15 = { -393, -180 };
+__m128d n16 = { 73.0, 63.18 };
+__m256 n17 = { -183.3, -22.3, 13.9, -119.3, 483.1, 122.3, -33.4, -9.37 };
+__m128 n18 = { -183.3, 22.3, 13.4, -19.03 };
+
+__m128 e1;
+struct m256d e2;
+__m128i e3;
+int e4;
+double e5;
+__m128i e6;
+__m128d e7;
+struct m256d e8;
+__m128 e9;
+__m128i e10;
+int e11;
+double e12;
+__m128i e13;
+__m256i e14;
+__m128i e15;
+__m128d e16;
+__m256 e17;
+__m128 e18;
+
+static void
+__attribute__((noinline))
+foo (va_list va_arglist)
+{
+ e4 = va_arg (va_arglist, int);
+ e5 = va_arg (va_arglist, double);
+ e6 = va_arg (va_arglist, __m128i);
+ e7 = va_arg (va_arglist, __m128d);
+ e8 = va_arg (va_arglist, struct m256d);
+ e9 = va_arg (va_arglist, __m128);
+ e10 = va_arg (va_arglist, __m128i);
+ e11 = va_arg (va_arglist, int);
+ e12 = va_arg (va_arglist, double);
+ e13 = va_arg (va_arglist, __m128i);
+ e14 = va_arg (va_arglist, __m256i);
+ e15 = va_arg (va_arglist, __m128i);
+ e16 = va_arg (va_arglist, __m128d);
+ e17 = va_arg (va_arglist, __m256);
+ e18 = va_arg (va_arglist, __m128);
+ va_end (va_arglist);
+}
+
+static void
+__attribute__((noinline))
+test (__m128 a1, struct m256d a2, __m128i a3, ...)
+{
+ va_list va_arglist;
+
+ e1 = a1;
+ e2 = a2;
+ e3 = a3;
+ va_start (va_arglist, a3);
+ foo (va_arglist);
+ va_end (va_arglist);
+}
+
+static void
+avx_test (void)
+{
+ test (n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12,
+ n13, n14, n15, n16, n17, n18);
+ assert (__builtin_memcmp (&e1, &n1, sizeof (e1)) == 0);
+ assert (__builtin_memcmp (&e2, &n2, sizeof (e2)) == 0);
+ assert (__builtin_memcmp (&e3, &n3, sizeof (e3)) == 0);
+ assert (n4 == e4);
+ assert (n5 == e5);
+ assert (__builtin_memcmp (&e6, &n6, sizeof (e6)) == 0);
+ assert (__builtin_memcmp (&e7, &n7, sizeof (e7)) == 0);
+ assert (__builtin_memcmp (&e8, &n8, sizeof (e8)) == 0);
+ assert (__builtin_memcmp (&e9, &n9, sizeof (e9)) == 0);
+ assert (__builtin_memcmp (&e10, &n10, sizeof (e10)) == 0);
+ assert (n11 == e11);
+ assert (n12 == e12);
+ assert (__builtin_memcmp (&e13, &n13, sizeof (e13)) == 0);
+ assert (__builtin_memcmp (&e14, &n14, sizeof (e14)) == 0);
+ assert (__builtin_memcmp (&e15, &n15, sizeof (e15)) == 0);
+ assert (__builtin_memcmp (&e16, &n16, sizeof (e16)) == 0);
+ assert (__builtin_memcmp (&e17, &n17, sizeof (e17)) == 0);
+ assert (__builtin_memcmp (&e18, &n18, sizeof (e18)) == 0);
+}
Index: gcc.target/i386/vararg-3.c
===================================================================
--- gcc.target/i386/vararg-3.c (revision 0)
+++ gcc.target/i386/vararg-3.c (revision 0)
@@ -0,0 +1,85 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -msse2" } */
+
+#include <stdarg.h>
+#include <assert.h>
+
+#include "sse2-check.h"
+
+__m128 n1 = { -283.3, -23.3, 213.4, 1119.03 };
+__m128d n2 = { -93.83, 893.318 };
+__m128i n3 = { 893, -3180 } ;
+int n4 = 324;
+double n5 = 103.3;
+__m128i n6 = { -123, 2 };
+__m128d n7 = { -91.387, -8193.518 };
+__m128 n8 = { -123.3, 2.3, 3.4, -10.03 };
+__m128i n9 = { 1233, -100 };
+int n10 = 407;
+double n11 = 304.9;
+__m128i n12 = { 233, -110 };
+__m128i n13 = { -393, -180 };
+__m128d n14 = { 73.0, 63.18 };
+__m128 n15 = { -183.3, 22.3, 13.4, -19.03 };
+
+__m128 e1;
+__m128d e2;
+__m128i e3;
+int e4;
+double e5;
+__m128i e6;
+__m128d e7;
+__m128 e8;
+__m128i e9;
+int e10;
+double e11;
+__m128i e12;
+__m128i e13;
+__m128d e14;
+__m128 e15;
+
+static void
+__attribute__((noinline))
+test (__m128 a1, __m128d a2, __m128i a3, ...)
+{
+ va_list va_arglist;
+
+ e1 = a1;
+ e2 = a2;
+ e3 = a3;
+ va_start (va_arglist, a3);
+ e4 = va_arg (va_arglist, int);
+ e5 = va_arg (va_arglist, double);
+ e6 = va_arg (va_arglist, __m128i);
+ e7 = va_arg (va_arglist, __m128d);
+ e8 = va_arg (va_arglist, __m128);
+ e9 = va_arg (va_arglist, __m128i);
+ e10 = va_arg (va_arglist, int);
+ e11 = va_arg (va_arglist, double);
+ e12 = va_arg (va_arglist, __m128i);
+ e13 = va_arg (va_arglist, __m128i);
+ e14 = va_arg (va_arglist, __m128d);
+ e15 = va_arg (va_arglist, __m128);
+ va_end (va_arglist);
+}
+
+static void
+sse2_test (void)
+{
+ test (n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15);
+ assert (__builtin_memcmp (&e1, &n1, sizeof (e1)) == 0);
+ assert (__builtin_memcmp (&e2, &n2, sizeof (e2)) == 0);
+ assert (__builtin_memcmp (&e3, &n3, sizeof (e3)) == 0);
+ assert (n4 == e4);
+ assert (n5 == e5);
+ assert (__builtin_memcmp (&e6, &n6, sizeof (e6)) == 0);
+ assert (__builtin_memcmp (&e7, &n7, sizeof (e7)) == 0);
+ assert (__builtin_memcmp (&e8, &n8, sizeof (e8)) == 0);
+ assert (__builtin_memcmp (&e9, &n9, sizeof (e9)) == 0);
+ assert (n10 == e10);
+ assert (n11 == e11);
+ assert (__builtin_memcmp (&e12, &n12, sizeof (e12)) == 0);
+ assert (__builtin_memcmp (&e13, &n13, sizeof (e13)) == 0);
+ assert (__builtin_memcmp (&e14, &n14, sizeof (e14)) == 0);
+ assert (__builtin_memcmp (&e15, &n15, sizeof (e15)) == 0);
+}