re PR tree-optimization/37541 (VRP fails to optimize single-bit ranges)
[gcc.git] / gcc / testsuite / gcc.dg / tree-ssa / pr37508.c
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -fdump-tree-vrp1" } */
3
4 struct foo1 {
5 int i:1;
6 };
7 struct foo2 {
8 unsigned i:1;
9 };
10
11 int test1 (struct foo1 *x)
12 {
13 if (x->i == 0)
14 return 1;
15 else if (x->i == -1)
16 return 1;
17 return 0;
18 }
19
20 int test2 (struct foo2 *x)
21 {
22 if (x->i == 0)
23 return 1;
24 else if (x->i == -1)
25 return 1;
26 return 0;
27 }
28
29 int test3 (struct foo1 *x)
30 {
31 if (x->i == 0)
32 return 1;
33 else if (x->i == 1) /* This test is already folded to false by fold. */
34 return 1;
35 return 0;
36 }
37
38 int test4 (struct foo2 *x)
39 {
40 if (x->i == 0)
41 return 1;
42 else if (x->i == 1)
43 return 1;
44 return 0;
45 }
46
47 /* { dg-final { scan-tree-dump-times "Folding" 3 "vrp1" } } */
48 /* { dg-final { cleanup-tree-dump "vrp1" } } */