2011-05-06 Gary Funck <gary@intrepid.com>
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / pr48258-2.c
blob443fb624e30114c982dd4d08190634dd21f7a9c1
1 /* { dg-do compile } */
2 /* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
3 /* { dg-require-effective-target powerpc_vsx_ok } */
4 /* { dg-options "-O3 -mcpu=power7 -mabi=altivec -ffast-math -fno-unroll-loops" } */
5 /* { dg-final { scan-assembler-times "xvadddp" 1 } } */
6 /* { dg-final { scan-assembler-times "xvmindp" 1 } } */
7 /* { dg-final { scan-assembler-times "xvmaxdp" 1 } } */
8 /* { dg-final { scan-assembler-times "xsadddp" 1 } } */
9 /* { dg-final { scan-assembler-times "xsmindp" 1 } } */
10 /* { dg-final { scan-assembler-times "xsmaxdp" 1 } } */
11 /* { dg-final { scan-assembler-not "xxsldwi" } } */
12 /* { dg-final { scan-assembler-not "stvx" } } */
13 /* { dg-final { scan-assembler-not "stxvd2x" } } */
14 /* { dg-final { scan-assembler-not "stxvw4x" } } */
16 #include <stddef.h>
18 #ifndef SIZE
19 #define SIZE 1024
20 #endif
22 double values[SIZE] __attribute__((__aligned__(32)));
24 double
25 vector_sum (void)
27 size_t i;
28 double sum = 0.0;
30 for (i = 0; i < SIZE; i++)
31 sum += values[i];
33 return sum;
36 double
37 vector_min (void)
39 size_t i;
40 double min = values[0];
42 for (i = 0; i < SIZE; i++)
43 min = __builtin_fmin (min, values[i]);
45 return min;
48 double
49 vector_max (void)
51 size_t i;
52 double max = values[0];
54 for (i = 0; i < SIZE; i++)
55 max = __builtin_fmax (max, values[i]);
57 return max;