2018-06-05 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / c-c++-common / unroll-2.c
blob635b6c25349ed0f7dc5a68f14c16233a5bae020d
1 /* { dg-do compile } */
2 /* { dg-options "-O -fdump-tree-cunroll-details -fdump-rtl-loop2_unroll-details" } */
4 extern void bar (int);
6 int j;
8 void test (void)
10 #pragma GCC unroll 8
11 for (unsigned long i = 1; i <= 8; ++i)
12 bar(i);
13 /* { dg-final { scan-tree-dump "11:.*: note: loop with 7 iterations completely unrolled" "cunroll" } } */
15 #pragma GCC unroll 8
16 for (unsigned long i = 1; i <= 7; ++i)
17 bar(i);
18 /* { dg-final { scan-tree-dump "16:.*: note: loop with 6 iterations completely unrolled" "cunroll" } } */
20 #pragma GCC unroll 8
21 for (unsigned long i = 1; i <= 15; ++i)
22 bar(i);
23 /* { dg-final { scan-rtl-dump "21:.*: note: loop unrolled 7 times" "loop2_unroll" } } */
25 #pragma GCC unroll 8
26 for (unsigned long i = 1; i <= j; ++i)
27 bar(i);
28 /* { dg-final { scan-rtl-dump "26:.*: note: loop unrolled 7 times" "loop2_unroll" } } */
30 #pragma GCC unroll 7
31 for (unsigned long i = 1; i <= j; ++i)
32 bar(i);
33 /* { dg-final { scan-rtl-dump "31:.*: note: loop unrolled 3 times" "loop2_unroll" } } */
35 unsigned long i = 0;
36 #pragma GCC unroll 3
37 do {
38 bar(i);
39 } while (++i < 9);
40 /* { dg-final { scan-rtl-dump "3\[79\]:.*: note: loop unrolled 2 times" "loop2_unroll" } } */