OSDN Git Service

2010-01-21 Martin Jambor <mjambor@suse.cz>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / tree-ssa / loop-15.c
1 /* A test for # of iterations analysis (signed counter cannot wrap) and final
2    value replacement.  */
3
4 /* { dg-options "-O2 -fdump-tree-optimized" } */
5
6 int foo(void);
7
8 int bla(void)
9 {
10   int i, n = foo (), j;
11
12   j = 0;
13   /* The loop should be removed completely.  */
14   for (i = 1; i <= n; i++)
15     j += n;
16
17   /* Should be replaced with return n * n;  */
18   return j;
19 }
20
21 /* Since the loop is removed, there should be no addition.  */
22 /* { dg-final { scan-tree-dump-times "\\+" 0 "optimized" } } */
23 /* { dg-final { scan-tree-dump-times "n_. \\* n_." 1 "optimized" } } */
24
25 /* The if from the loop header copying remains in the code.  */
26 /* { dg-final { scan-tree-dump-times "if " 1 "optimized" } } */
27 /* { dg-final { cleanup-tree-dump "optimized" } } */