Debian Codegraph @

gcc/testsuite/gcc.dg/tree-ssa/loop-7.c

raw
1 /* PR tree-optimization/19828 */
2 /* { dg-do compile } */
3 /* { dg-options "-O1 -fdump-tree-lim2-details" } */
4
5 int cst_fun1 (int) __attribute__((__const__));
6 int cst_fun2 (int) __attribute__((__const__));
7 int pure_fun1 (int) __attribute__((__pure__));
8 int pure_fun2 (int) __attribute__((__pure__));
9 int foo (void);
10
11 int xxx (void)
12 {
13 int i, k = foo (), x = 0;
14
15 for (i = 0; i < 100; i++)
16 {
17 x += cst_fun1 (k);
18 x += pure_fun1 (k);
19
20 if (k)
21 {
22 x += cst_fun2 (k);
23 x += pure_fun2 (k);
24 }
25 }
26
27 return x;
28 }
29
30 /* Calls to cst_fun1 and pure_fun1 may be moved out of the loop.
31 Calls to cst_fun2 and pure_fun2 should not be, since calling
32 with k = 0 may be invalid. */
33
34 /* { dg-final { scan-tree-dump-times "Moving statement" 2 "lim2" } } */