Merge -r 127928:132243 from trunk
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / vect-reduc-7.c
bloba59a24ac7372626b343e7d36a10842af389b2825
1 /* { dg-require-effective-target vect_int } */
3 #include "tree-vect.h"
5 #define N 32
7 extern void abort (void);
8 typedef unsigned char T;
10 __attribute__ ((noinline)) void
11 testmax (const T *c, T init, T result)
13 T lc[N], accum = init;
14 int i;
16 __builtin_memcpy (lc, c, sizeof(lc));
18 for (i = 0; i < N; i++) {
19 accum = accum < lc[i] ? lc[i] : accum;
22 if (accum != result)
23 abort ();
26 __attribute__ ((noinline)) void
27 testmin (const T *c, T init, T result)
29 T lc[N], accum = init;
30 int i;
32 __builtin_memcpy (lc, c, sizeof(lc));
34 for (i = 0; i < N; i++) {
35 accum = accum > lc[i] ? lc[i] : accum;
38 if (accum != result)
39 abort ();
42 int main (void)
44 static unsigned char const A[N] = {
45 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
46 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
47 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
48 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f
51 static unsigned char const B[N] = {
52 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
53 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
54 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
55 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f
58 static unsigned char const C[N] = {
59 0xff, 0xfe, 0xfd, 0xfc, 0xfb, 0xfa, 0xf9, 0xf8,
60 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
61 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
62 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
65 check_vect ();
67 testmin (A, 10, 1);
68 testmin (B, 0x7f, 0x70);
69 testmin (C, 0x7f, 0x09);
71 testmax (A, 0, 0x7f);
72 testmax (B, 0, 0x8f);
73 testmax (C, 0, 0xff);
75 return 0;
78 /* { dg-final { cleanup-tree-dump "vect" } } */