2009-07-17 Richard Guenther <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / fast-math-vect-reduc-7.c
blob9f36db2e70120a4793ece801062b29ca94ed67bf
1 /* { dg-require-effective-target vect_double } */
3 /* need -funsafe-math-optimizations to vectorize the summation.
4 also need -ffinite-math-only to create the min/max expr. */
6 #include <stdarg.h>
7 #include "tree-vect.h"
9 #define N 16
10 #define DIFF 242
12 double b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45};
13 double c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
15 int main1 (double x, double max_result)
17 int i;
18 double diff = 2;
19 double max = x;
20 double min = 10;
22 for (i = 0; i < N; i++) {
23 diff += (b[i] - c[i]);
26 for (i = 0; i < N; i++) {
27 max = max < c[i] ? c[i] : max;
30 for (i = 0; i < N; i++) {
31 min = min > c[i] ? c[i] : min;
34 /* check results: */
35 if (diff != DIFF)
36 abort ();
37 if (max != max_result)
38 abort ();
39 if (min != 0)
40 abort ();
42 return 0;
45 int main (void)
47 check_vect ();
49 main1 (100, 100);
50 main1 (0, 15);
51 return 0;
54 /* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" } } */
55 /* { dg-final { cleanup-tree-dump "vect" } } */