Debian Codegraph @

gcc/testsuite/gcc.dg/vect/vect-fmin-3.c

raw
1 /* { dg-require-effective-target vect_double } */
2
3 #include "tree-vect.h"
4
5 void __attribute__((noipa))
6 test (double x0, double x1, double *restrict res, double *restrict ptr, int n)
7 {
8 for (int i = 0; i < n; i += 2)
9 {
10 x0 = __builtin_fmin (x0, ptr[i + 0]);
11 x1 = __builtin_fmin (x1, ptr[i + 1]);
12 }
13 res[0] = x0;
14 res[1] = x1;
15 }
16
17 #define N 128
18 #define HALF (N / 2)
19
20 int
21 main (void)
22 {
23 check_vect ();
24
25 double res[2], a[N];
26
27 for (int i = 0; i < N; i += 2)
28 {
29 a[i] = i < HALF ? HALF - i : 0;
30 a[i + 1] = -i / 8;
31 }
32
33 test (N, N, res, a, 2);
34 if (res[0] != HALF || res[1] != 0)
35 __builtin_abort ();
36
37 test (N, N, res, a, 6);
38 if (res[0] != HALF - 4 || res[1] != 0)
39 __builtin_abort ();
40
41 test (N, N, res, a, 8);
42 if (res[0] != HALF - 6 || res[1] != 0)
43 __builtin_abort ();
44
45 test (N, N, res, a, 10);
46 if (res[0] != HALF - 8 || res[1] != -1)
47 __builtin_abort ();
48
49 test (N, N, res, a, HALF - 2);
50 if (res[0] != 4 || res[1] != -HALF / 8 + 1)
51 __builtin_abort ();
52
53 test (N, N, res, a, HALF);
54 if (res[0] != 2 || res[1] != -HALF / 8 + 1)
55 __builtin_abort ();
56
57 test (N, N, res, a, HALF + 2);
58 if (res[0] != 0 || res[1] != -HALF / 8)
59 __builtin_abort ();
60
61 test (N, N, res, a, HALF + 8);
62 if (res[0] != 0 || res[1] != -HALF / 8)
63 __builtin_abort ();
64
65 test (N, N, res, a, HALF + 10);
66 if (res[0] != 0 || res[1] != -HALF / 8 - 1)
67 __builtin_abort ();
68
69 test (N, N, res, a, N);
70 if (res[0] != 0 || res[1] != -N / 8 + 1)
71 __builtin_abort ();
72
73 test (-1, N, res, a, N);
74 if (res[0] != -1 || res[1] != -N / 8 + 1)
75 __builtin_abort ();
76
77 test (-1, -N / 8, res, a, N);
78 if (res[0] != -1 || res[1] != -N / 8)
79 __builtin_abort ();
80
81 return 0;
82 }
83
84 /* { dg-final { scan-tree-dump "Detected reduction" "vect" } } */
85 /* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" { target vect_max_reduc } } } */