aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-27.c
blob: c699bc6ac80420b4a424732f7bcba46473f0fff8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/* { dg-do compile } */ 
/* { dg-options "-O1 -fscalar-evolutions -fdump-tree-scev-details" } */


int bar (void);

int foo ()
{
  int a = -100;
  
  /* This exercises a code with two loop nests.  */
  
  /* loop_1 runs 100 times.  */
  while (a < 0)
    a++;
  
  a -= 77;
  
  /* loop_2 runs 26 times.  */
  while (a < 0)
    a+=3;
}

/* The analyzer sees two loop nests:
   for the first, it determines the evolution:
   a  ->  {-100, +, 1}_1
   
   and for the second, it determines that the first loop ends at 0 and then:
   a  ->  {-77, +, 3}_2
   
   When the constant propagation is postponed, the analyzer detects
   for the second loop the evolution function:
   a  ->  {a_5, +, 3}_2

*/

/* { dg-final { scan-tree-dump-times "nb_iterations 100" 1 "scev"} } */
/* { dg-final { scan-tree-dump-times "nb_iterations 26" 1 "scev"} } */