1 /* { dg-do compile } */
2 /* { dg-options "-O2 -ftree-parallelize-loops=4 -fdump-tree-parloops-details -fdump-tree-optimized" } */
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
;
17 __builtin_memcpy (lc
, c
, sizeof(lc
));
19 for (i
= 0; i
< N
; i
++) {
20 accum
= accum
< lc
[i
] ? lc
[i
] : accum
;
27 __attribute__ ((noinline
)) void
28 testmin (const T
*c
, T init
, T result
)
30 T lc
[N
], accum
= init
;
33 __builtin_memcpy (lc
, c
, sizeof(lc
));
35 for (i
= 0; i
< N
; i
++) {
36 accum
= accum
> lc
[i
] ? lc
[i
] : accum
;
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,
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);
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" } } */