1 /* { dg-do compile } */
2 /* { dg-options "-O2 -fdump-tree-evrp-details -fdump-tree-vrp1-details" } */
3 
4 static int blocksize = 4096;
5 
6 int bar (int);
7 
foo(void)8 void foo (void)
9 {
10   int toread;
11   int bytes;
12   __attribute__ ((used))
13   static char eof_reached = 0;
14 
15   toread = blocksize;
16   bytes = 1;
17 
18   while (toread != 0)
19     {
20       bytes = bar (toread);
21       if (bytes <= 0)
22         {
23           if (bytes < 0)
24             continue;
25           break;
26         }
27       toread -= bytes;
28     }
29 
30   if (bytes == 0)
31     eof_reached = 1;
32 }
33 
34 
35 /* First, we should simplify the bits < 0 test within the loop.  */
36 /* { dg-final { scan-tree-dump-times "Simplified relational" 1 "evrp" } } */
37 
38 /* Second, we should thread the edge out of the loop via the break
39    statement.  We also realize that the final bytes == 0 test is useless,
40    and thread over it.  We also know that toread != 0 is useless when
41    entering while loop and thread over it.  */
42 /* { dg-final { scan-tree-dump-times "Threaded jump" 3 "vrp1" } } */
43 
44 
45