re PR tree-optimization/33291 (a+=2; a+=2 not simplified to a+=4; with -O3 ...
[gcc.git] / gcc / testsuite / gcc.dg / tree-ssa / vrp03.c
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -fdump-tree-vrp1" } */
3
4 struct A
5 {
6 int a;
7 int b;
8 };
9
10 foo (struct A *p, struct A *q)
11 {
12 int *r = 0;
13
14 if (p)
15 {
16 if (p == q)
17 {
18 /* This should be folded to 'if (1)' because q is [p, p]
19 and p is ~[0, 0]. */
20 if (q)
21 r = &q->a;
22
23 /* This should be folded to 'if (1)' because q should be
24 ~[0, 0] and thus &q->a should be ~[0, 0]. */
25 if (r)
26 return 5;
27 }
28 }
29
30 return q->a;
31 }
32
33 /* { dg-final { scan-tree-dump-times "Folding predicate q_.*to 1" 1 "vrp1" } } */
34 /* { dg-final { scan-tree-dump-times "Folding predicate r_.*to 1" 1 "vrp1" } } */
35 /* { dg-final { cleanup-tree-dump "vrp1" } } */