2018-05-18 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.dg / tree-ssa / pr21559.c
blobb4065668ff8f684a45fbd49283da50cc5a6dae9c
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -fdump-tree-evrp-details -fdump-tree-vrp1-details" } */
4 static int blocksize = 4096;
6 int bar (int);
8 void foo (void)
10 int toread;
11 int bytes;
12 __attribute__ ((used))
13 static char eof_reached = 0;
15 toread = blocksize;
16 bytes = 1;
18 while (toread != 0)
20 bytes = bar (toread);
21 if (bytes <= 0)
23 if (bytes < 0)
24 continue;
25 break;
27 toread -= bytes;
30 if (bytes == 0)
31 eof_reached = 1;
35 /* First, we should simplify the bits < 0 test within the loop. */
36 /* { dg-final { scan-tree-dump-times "Simplified relational" 1 "evrp" } } */
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" } } */