gcc/testsuite/gcc.dg/vect/vect-cond-5.c
raw| 1 | /* { dg-require-effective-target vect_condition } */ |
| 2 | |
| 3 | #include <stdarg.h> |
| 4 | #include "tree-vect.h" |
| 5 | |
| 6 | #define K 32 |
| 7 | |
| 8 | int cond_array[2*K][K] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); |
| 9 | int a[K][K] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); |
| 10 | int out[K]; |
| 11 | int check_result[K] = {2,2,2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; |
| 12 | |
| 13 | __attribute__ ((noinline)) void |
| 14 | foo (int c) |
| 15 | { |
| 16 | int res, i, j, k, next; |
| 17 | |
| 18 | for (k = 0; k < K; k++) |
| 19 | { |
| 20 | res = 0; |
| 21 | for (j = 0; j < K; j++) |
| 22 | for (i = 0; i < K; i++) |
| 23 | { |
| 24 | next = a[i][j]; |
| 25 | res = c > cond_array[i+k][j] ? next : res; |
| 26 | } |
| 27 | |
| 28 | out[k] = res; |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | int main () |
| 33 | { |
| 34 | int i, j, k; |
| 35 | |
| 36 | check_vect (); |
| 37 | |
| 38 | for (j = 0; j < K; j++) |
| 39 | { |
| 40 | for (i = 0; i < 2*K; i++) |
| 41 | cond_array[i][j] = i+j; |
| 42 | |
| 43 | for (i = 0; i < K; i++) |
| 44 | a[i][j] = i+2; |
| 45 | } |
| 46 | |
| 47 | foo(5); |
| 48 | |
| 49 | #pragma GCC novector |
| 50 | for (k = 0; k < K; k++) |
| 51 | if (out[k] != check_result[k]) |
| 52 | abort (); |
| 53 | |
| 54 | return 0; |
| 55 | } |
| 56 | |
| 57 | /* Double reduction with cond_expr is not supported, since even though the order |
| 58 | of computation is the same, but vector results should be reduced to scalar |
| 59 | result, which can'be done for cond_expr. */ |
| 60 | /* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" { xfail *-*-* } } } */ |
| 61 |