Merge from mainline
[official-gcc.git] / gcc / testsuite / gcc.dg / tree-ssa / loop-15.c
blobad0995d262ca91210b8442a58d590da3eade086d
1 /* A test for # of iterations analysis (signed counter cannot wrap) and final
2 value replacement. */
4 /* { dg-options "-O2 -fdump-tree-optimized" } */
6 int foo(void);
8 int bla(void)
10 int i, n = foo (), j;
12 j = 0;
13 /* The loop should be removed completely. */
14 for (i = 1; i <= n; i++)
15 j += n;
17 /* Should be replaced with return n * n; */
18 return j;
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" } } */
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" } } */