| 1 |
/* { dg-require-effective-target vect_float } */ |
| 2 |
|
| 3 |
#include "tree-vect.h" |
| 4 |
|
| 5 |
#ifndef TYPE |
| 6 |
#define TYPE float |
| 7 |
#define FN __builtin_fmaxf |
| 8 |
#endif |
| 9 |
|
| 10 |
TYPE __attribute__((noipa)) |
| 11 |
test (TYPE x, TYPE *ptr, int n) |
| 12 |
{ |
| 13 |
for (int i = 0; i < n; ++i) |
| 14 |
x = FN (x, ptr[i]); |
| 15 |
return x; |
| 16 |
} |
| 17 |
|
| 18 |
#define N 128 |
| 19 |
#define HALF (N / 2) |
| 20 |
|
| 21 |
int |
| 22 |
main (void) |
| 23 |
{ |
| 24 |
check_vect (); |
| 25 |
|
| 26 |
TYPE a[N]; |
| 27 |
|
| 28 |
for (int i = 0; i < N; ++i) |
| 29 |
a[i] = i; |
| 30 |
|
| 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 (); |
| 47 |
|
| 48 |
for (int i = 0; i < N; ++i) |
| 49 |
a[i] = -i; |
| 50 |
|
| 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 (); |
| 57 |
|
| 58 |
for (int i = 0; i < HALF; ++i) |
| 59 |
{ |
| 60 |
a[i] = i; |
| 61 |
a[HALF + i] = HALF - i; |
| 62 |
} |
| 63 |
|
| 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 (); |
| 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 } } } */ |