libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / vect-fmax-1.c
blobd3aa5b06ab9e82f65531ca90374fbaa53eff5fdb
1 /* { dg-require-effective-target vect_float } */
3 #include "tree-vect.h"
5 #ifndef TYPE
6 #define TYPE float
7 #define FN __builtin_fmaxf
8 #endif
10 TYPE __attribute__((noipa))
11 test (TYPE x, TYPE *ptr, int n)
13 for (int i = 0; i < n; ++i)
14 x = FN (x, ptr[i]);
15 return x;
18 #define N 128
19 #define HALF (N / 2)
21 int
22 main (void)
24 check_vect ();
26 TYPE a[N];
28 for (int i = 0; i < N; ++i)
29 a[i] = i;
31 if (test (-1, a, 1) != 0)
32 __builtin_abort ();
33 if (test (-1, a, 64) != 63)
34 __builtin_abort ();
35 if (test (-1, a, 65) != 64)
36 __builtin_abort ();
37 if (test (-1, a, 66) != 65)
38 __builtin_abort ();
39 if (test (-1, a, 67) != 66)
40 __builtin_abort ();
41 if (test (-1, a, 128) != 127)
42 __builtin_abort ();
43 if (test (127, a, 128) != 127)
44 __builtin_abort ();
45 if (test (128, a, 128) != 128)
46 __builtin_abort ();
48 for (int i = 0; i < N; ++i)
49 a[i] = -i;
51 if (test (-60, a, 4) != 0)
52 __builtin_abort ();
53 if (test (0, a, 4) != 0)
54 __builtin_abort ();
55 if (test (1, a, 4) != 1)
56 __builtin_abort ();
58 for (int i = 0; i < HALF; ++i)
60 a[i] = i;
61 a[HALF + i] = HALF - i;
64 if (test (0, a, HALF - 16) != HALF - 17)
65 __builtin_abort ();
66 if (test (0, a, HALF - 2) != HALF - 3)
67 __builtin_abort ();
68 if (test (0, a, HALF - 1) != HALF - 2)
69 __builtin_abort ();
70 if (test (0, a, HALF) != HALF - 1)
71 __builtin_abort ();
72 if (test (0, a, HALF + 1) != HALF)
73 __builtin_abort ();
74 if (test (0, a, HALF + 2) != HALF)
75 __builtin_abort ();
76 if (test (0, a, HALF + 3) != HALF)
77 __builtin_abort ();
78 if (test (0, a, HALF + 16) != HALF)
79 __builtin_abort ();
81 return 0;
84 /* { dg-final { scan-tree-dump "Detected reduction" "vect" } } */
85 /* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" { target vect_max_reduc } } } */