OSDN Git Service

2007-12-06 Zdenek Dvorak <ook@ucw.cz>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / vect / vect-reduc-1short.c
1 /* { dg-require-effective-target vect_int } */
2
3 #include <stdarg.h>
4 #include "tree-vect.h"
5
6 #define N 16
7 #define DIFF 242
8
9 __attribute__ ((noinline)) void
10 main1 (unsigned short x, unsigned short max_result, unsigned short min_result)
11 {
12   int i;
13   unsigned short ub[N] = {1,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45};
14   unsigned short uc[N] = {1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
15   unsigned short  udiff = 2;
16   unsigned short umax = x;
17   unsigned short umin = x;
18
19   for (i = 0; i < N; i++) {
20     udiff += (unsigned short)(ub[i] - uc[i]);
21   }
22
23   for (i = 0; i < N; i++) {
24     umax = umax < uc[i] ? uc[i] : umax;
25   }
26
27   for (i = 0; i < N; i++) {
28     umin = umin > uc[i] ? uc[i] : umin;
29   }
30
31   /* check results:  */
32   if (udiff != DIFF)
33     abort ();
34   if (umax != max_result)
35     abort ();
36   if (umin != min_result)
37     abort ();
38 }
39
40 int main (void)
41
42   check_vect ();
43   
44   main1 (100, 100, 1);
45   main1 (0, 15, 0);
46   return 0;
47 }
48
49 /* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" { xfail vect_no_int_max } } } */
50 /* { dg-final { cleanup-tree-dump "vect" } } */