OSDN Git Service

2010-12-30 Kai Tietz <kai.tietz@onevision.com>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.target / i386 / opt-2.c
1 /* Test the attribute((optimize)) really works.  Do this test by checking
2    whether we vectorize a simple loop.  */
3 /* { dg-do compile } */
4 /* { dg-options "-O1 -msse2 -mfpmath=sse -march=k8" } */
5 /* { dg-final { scan-assembler "prefetcht0" } } */
6 /* { dg-final { scan-assembler "addps" } } */
7 /* { dg-final { scan-assembler "subss" } } */
8
9 #define SIZE 10240
10 float a[SIZE] __attribute__((__aligned__(32)));
11 float b[SIZE] __attribute__((__aligned__(32)));
12 float c[SIZE] __attribute__((__aligned__(32)));
13
14 /* This should vectorize.  */
15 #pragma GCC push_options
16 #pragma GCC optimize (3, "unroll-all-loops", "-fprefetch-loop-arrays")
17
18 void
19 opt3 (void)
20 {
21   int i;
22
23   for (i = 0; i < SIZE; i++)
24     a[i] = b[i] + c[i];
25 }
26
27 #pragma GCC pop_options
28
29 /* This should not vectorize.  */
30 void
31 not_opt3 (void)
32 {
33   int i;
34
35   for (i = 0; i < SIZE; i++)
36     a[i] = b[i] - c[i];
37 }
38