2018-01-16 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / vect-reduc-or_1.c
blobcff3f16107f2355fb4e38b3b66596253545ec796
1 /* { dg-do run { target { whole_vector_shift || vect_logical_reduc } } } */
3 /* Write a reduction loop to be reduced using vector shifts. */
5 #include "tree-vect.h"
7 #if VECTOR_BITS > 128
8 #define N (VECTOR_BITS / 8)
9 #else
10 #define N 16
11 #endif
13 extern void abort(void);
15 unsigned char in[N] __attribute__((__aligned__(16)));
17 int
18 main (unsigned char argc, char **argv)
20 unsigned char i = 0;
21 unsigned char sum = 1;
22 unsigned char expected = 1;
24 check_vect ();
26 for (i = 0; i < N; i++)
28 in[i] = (i + i + 1) & 0xfd;
29 asm volatile ("" ::: "memory");
32 for (i = 0; i < N; i++)
34 expected |= in[i];
35 asm volatile ("" ::: "memory");
38 for (i = 0; i < N; i++)
39 sum |= in[i];
41 if (sum != expected)
43 __builtin_printf("Failed %d\n", sum);
44 abort();
47 return 0;
50 /* { dg-final { scan-tree-dump "Reduce using vector shifts" "vect" { target { ! vect_logical_reduc } } } } */
51 /* { dg-final { scan-tree-dump "Reduce using direct vector reduction" "vect" { target vect_logical_reduc } } } */