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 
bla(void)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" { xfail *-*-* } } } */
23 /* { dg-final { scan-tree-dump-times " \\* " 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