Merge from mainline (151362:151806)
[official-gcc/graphite-test-results.git] / gcc / testsuite / gcc.dg / autopar / reduc-9.c
blob2c1677ce5eec8ecd1fba933c0531cd404ef4d46a
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -ftree-parallelize-loops=4 -fdump-tree-parloops-details -fdump-tree-optimized" } */
4 #include <stdlib.h>
6 #define N 3200
8 extern void abort (void);
9 typedef unsigned short T;
11 __attribute__ ((noinline)) void
12 testmax (const T *c, T init, T result)
14 T lc[N], accum = init;
15 int i;
17 __builtin_memcpy (lc, c, sizeof(lc));
19 for (i = 0; i < N; i++) {
20 accum = accum < lc[i] ? lc[i] : accum;
23 if (accum != result)
24 abort ();
27 __attribute__ ((noinline)) void
28 testmin (const T *c, T init, T result)
30 T lc[N], accum = init;
31 int i;
33 __builtin_memcpy (lc, c, sizeof(lc));
35 for (i = 0; i < N; i++) {
36 accum = accum > lc[i] ? lc[i] : accum;
39 if (accum != result)
40 abort ();
43 int main (void)
45 static unsigned short A[N] = {
46 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008,
47 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f, 0x0010,
48 0x7000, 0x7100, 0x7200, 0x7300, 0x7400, 0x7500, 0x7600, 0x7700,
49 0x7ff8, 0x7ff9, 0x7ffa, 0x7ffb, 0x7ffc, 0x7ffd, 0x7ffe, 0x7fff
52 static unsigned short B[N] = {
53 0x7000, 0x7100, 0x7200, 0x7300, 0x7400, 0x7500, 0x7600, 0x7700,
54 0x7ff8, 0x7ff9, 0x7ffa, 0x7ffb, 0x7ffc, 0x7ffd, 0x7ffe, 0x7fff,
55 0x8000, 0x8001, 0x8002, 0x8003, 0x8004, 0x8005, 0x8006, 0x8007,
56 0x8008, 0x8009, 0x800a, 0x800b, 0x800c, 0x800d, 0x800e, 0x800f
59 static unsigned short C[N] = {
60 0xffff, 0xfffe, 0xfffd, 0xfffc, 0xfffb, 0xfffa, 0xfff9, 0xfff8,
61 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f, 0x0010,
62 0x8000, 0x8001, 0x8002, 0x8003, 0x8004, 0x8005, 0x8006, 0x8007,
63 0x7000, 0x7100, 0x7200, 0x7300, 0x7400, 0x7500, 0x7600, 0x7700,
66 int i;
68 for (i=32; i<N; i++)
70 A[i]= 0x0001;
71 B[i]= 0x7000;
72 C[i]= 0xffff;
75 testmin (A, 10, 1);
76 testmin (B, 0x7fff, 0x7000);
77 testmin (C, 0x7fff, 0x0009);
79 testmax (A, 0, 0x7fff);
80 testmax (B, 0, 0x800f);
81 testmax (C, 0, 0xffff);
83 return 0;
87 /* { dg-final { scan-tree-dump-times "Detected reduction" 2 "parloops" } } */
88 /* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 3 "parloops" } } */
89 /* { dg-final { cleanup-tree-dump "parloops" } } */
90 /* { dg-final { cleanup-tree-dump "optimized" } } */