re PR tree-optimization/33291 (a+=2; a+=2 not simplified to a+=4; with -O3 ...
[gcc.git] / gcc / testsuite / gcc.dg / tree-ssa / pr22117.c
1 /* PR tree-optimization/22117
2 VRP used think that &p[q] is nonzero even though p and q are both
3 known to be zero after entering the first two "if" statements. */
4
5 /* { dg-do compile } */
6 /* { dg-options "-O2 -fdump-tree-vrp1" } */
7
8 void
9 foo (int *p, int q)
10 {
11 if (p == 0)
12 {
13 if (q == 0)
14 {
15 int *r = &p[q];
16 if (r != 0)
17 link_error ();
18 }
19 }
20 }
21
22 /* { dg-final { scan-tree-dump-times "Folding predicate r_.* != 0B to 0" 1 "vrp1" } } */
23 /* { dg-final { cleanup-tree-dump "vrp1" } } */