Debian Codegraph @

gcc/testsuite/gcc.target/i386/pr106010-7b.c

raw
1 /* { dg-do run } */
2 /* { dg-options "-O2 -mavx -ftree-vectorize -fvect-cost-model=unlimited -mprefer-vector-width=256" } */
3 /* { dg-require-effective-target avx } */
4
5 #include "avx-check.h"
6 #include <string.h>
7 #include "pr106010-7a.c"
8
9 void
10 avx_test (void)
11 {
12 _Complex double* pd_src = (_Complex double*) malloc (2 * N * sizeof (double));
13 _Complex double* pd_dst = (_Complex double*) malloc (2 * N * sizeof (double));
14 _Complex float* ps_src = (_Complex float*) malloc (2 * N * sizeof (float));
15 _Complex float* ps_dst = (_Complex float*) malloc (2 * N * sizeof (float));
16 _Complex long long* epi64_src = (_Complex long long*) malloc (2 * N * sizeof (long long));
17 _Complex long long* epi64_dst = (_Complex long long*) malloc (2 * N * sizeof (long long));
18 _Complex int* epi32_src = (_Complex int*) malloc (2 * N * sizeof (int));
19 _Complex int* epi32_dst = (_Complex int*) malloc (2 * N * sizeof (int));
20 _Complex short* epi16_src = (_Complex short*) malloc (2 * N * sizeof (short));
21 _Complex short* epi16_dst = (_Complex short*) malloc (2 * N * sizeof (short));
22 _Complex char* epi8_src = (_Complex char*) malloc (2 * N * sizeof (char));
23 _Complex char* epi8_dst = (_Complex char*) malloc (2 * N * sizeof (char));
24 char* p_init = (char*) malloc (2 * N * sizeof (double));
25
26 __builtin_memset (pd_dst, 0, 2 * N * sizeof (double));
27 __builtin_memset (ps_dst, 0, 2 * N * sizeof (float));
28 __builtin_memset (epi64_dst, 0, 2 * N * sizeof (long long));
29 __builtin_memset (epi32_dst, 0, 2 * N * sizeof (int));
30 __builtin_memset (epi16_dst, 0, 2 * N * sizeof (short));
31 __builtin_memset (epi8_dst, 0, 2 * N * sizeof (char));
32
33 for (int i = 0; i != 2 * N * sizeof (double); i++)
34 p_init[i] = i % 2 + 3;
35
36 memcpy (pd_src, p_init, 2 * N * sizeof (double));
37 memcpy (ps_src, p_init, 2 * N * sizeof (float));
38 memcpy (epi64_src, p_init, 2 * N * sizeof (long long));
39 memcpy (epi32_src, p_init, 2 * N * sizeof (int));
40 memcpy (epi16_src, p_init, 2 * N * sizeof (short));
41 memcpy (epi8_src, p_init, 2 * N * sizeof (char));
42
43 foo_pd (pd_dst, pd_src[0]);
44 foo_ps (ps_dst, ps_src[0]);
45 foo_epi64 (epi64_dst, epi64_src[0]);
46 foo_epi32 (epi32_dst, epi32_src[0]);
47 foo_epi16 (epi16_dst, epi16_src[0]);
48 foo_epi8 (epi8_dst, epi8_src[0]);
49 if (__builtin_memcmp (pd_dst, pd_src, N * 2 * sizeof (double)) != 0)
50 __builtin_abort ();
51 if (__builtin_memcmp (ps_dst, ps_src, N * 2 * sizeof (float)) != 0)
52 __builtin_abort ();
53 if (__builtin_memcmp (epi64_dst, epi64_src, N * 2 * sizeof (long long)) != 0)
54 __builtin_abort ();
55 if (__builtin_memcmp (epi32_dst, epi32_src, N * 2 * sizeof (int)) != 0)
56 __builtin_abort ();
57 if (__builtin_memcmp (epi16_dst, epi16_src, N * 2 * sizeof (short)) != 0)
58 __builtin_abort ();
59 if (__builtin_memcmp (epi8_dst, epi8_src, N * 2 * sizeof (char)) != 0)
60 __builtin_abort ();
61
62 return;
63 }