libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / vect-93.c
blob75af52d6434913b6d5992d81601b672cdc5c622b
1 /* { dg-require-effective-target vect_float } */
2 /* { dg-additional-options "--param vect-max-peeling-for-alignment=0 -fdump-tree-optimized-details-blocks" } */
4 #include <stdarg.h>
5 #include "tree-vect.h"
7 #define N1 3001
9 #if VECTOR_BITS > 256
10 #define N2 (VECTOR_BITS / 32 + 2)
11 #else
12 #define N2 10
13 #endif
15 __attribute__ ((noinline)) int
16 main1 (float *pa)
18 int i;
20 for (i = 0; i < N1; i++)
22 pa[i] = 2.0;
25 /* check results: */
26 #pragma GCC novector
27 for (i = 0; i < N1; i++)
29 if (pa[i] != 2.0)
30 abort ();
33 #pragma GCC unroll 0
34 for (i = 1; i <= N2; i++)
36 pa[i] = 3.0;
39 /* check results: */
40 #pragma GCC novector
41 for (i = 1; i <= N2; i++)
43 if (pa[i] != 3.0)
44 abort ();
47 return 0;
50 int main (void)
52 int i;
53 float a[N1] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
54 float b[N1] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
56 check_vect ();
58 /* from bzip2: */
59 for (i = 0; i < N1; i++)
60 b[i] = i;
61 a[0] = 0;
62 for (i = 1; i <= 256; i++) a[i] = b[i-1];
64 /* check results: */
65 #pragma GCC novector
66 for (i = 1; i <= 256; i++)
68 if (a[i] != i-1)
69 abort ();
71 if (a[0] != 0)
72 abort ();
74 main1 (a);
76 return 0;
79 /* 2 loops vectorized in main1, 2 loops vectorized in main:
80 the first loop in main requires vectorization of conversions,
81 the second loop in main requires vectorization of misaligned load. */
83 /* main && main1 together: */
84 /* { dg-final { scan-tree-dump-times "vectorized 2 loops" 2 "vect" { target powerpc*-*-* i?86-*-* x86_64-*-* } } } */
86 /* in main1: */
87 /* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" { target !powerpc*-*-* !i?86-*-* !x86_64-*-* } } } */
88 /* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" { target { vect_no_align && { ! vect_hw_misalign } } } } } */
90 /* in main: */
91 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { vect_no_align && { ! vect_hw_misalign } } } } } */
93 /* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */