| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-O2 -fdump-tree-vrp1 -fdelete-null-pointer-checks -fdisable-tree-evrp -fno-thread-jumps" } */ |
| 3 |
|
| 4 |
struct A |
| 5 |
{ |
| 6 |
int a; |
| 7 |
int b; |
| 8 |
}; |
| 9 |
|
| 10 |
int |
| 11 |
foo (struct A *p, struct A *q) |
| 12 |
{ |
| 13 |
int x = p->a; |
| 14 |
if (p == q) |
| 15 |
return q->a; |
| 16 |
|
| 17 |
/* We should fold this to 'if (1)' but the assertion for 'p == q' |
| 18 |
was overwriting the assertion 'p != 0' from the first dereference |
| 19 |
of 'p'. */ |
| 20 |
if (p) |
| 21 |
return x + p->b; |
| 22 |
} |
| 23 |
/* Target disabling -fdelete-null-pointer-checks should not fold check */ |
| 24 |
/* { dg-final { scan-tree-dump-times "Folding predicate p_.*to 1" 1 "vrp1" { target { ! keeps_null_pointer_checks } } } } */ |
| 25 |
/* { dg-final { scan-tree-dump-times "Folding predicate p_.*to 1" 0 "vrp1" { target { keeps_null_pointer_checks } } } } */ |