PR tree-optimization/84740
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / vect-reduc-6.c
blobad148046a8eca15bfdb41335f4f91c219c31b71a
1 /* { dg-require-effective-target vect_float_strict } */
2 /* { dg-additional-options "-fno-fast-math" } */
4 #include <stdarg.h>
5 #include "tree-vect.h"
7 #define N 16
8 #define DIFF 242
10 __attribute__ ((noinline))
11 int main1 (float x, float max_result)
13 int i;
14 float b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45};
15 float c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
16 float diff = 2;
17 float max = x;
18 float min = 10;
20 for (i = 0; i < N; i++) {
21 diff += (b[i] - c[i]);
24 for (i = 0; i < N; i++) {
25 max = max < c[i] ? c[i] : max;
28 for (i = 0; i < N; i++) {
29 min = min > c[i] ? c[i] : min;
32 /* check results: */
33 if (diff != DIFF)
34 abort ();
35 if (max != max_result)
36 abort ();
37 if (min != 0)
38 abort ();
40 return 0;
43 int main (void)
45 check_vect ();
47 main1 (100 ,100);
48 main1 (0, 15);
49 return 0;
52 /* { dg-final { scan-tree-dump-times {using an in-order \(fold-left\) reduction} 1 "vect" } } */
53 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */