blob: 6584919b560ed285fc26f2f24e2c82bff1851478 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-vrp1-details" } */
foo (int i, int *p)
{
int j;
if (i > 10)
{
if (p)
{
j = *p;
/* This should be folded to if (1) because of the parent 'if
(p)'. But the dereference of p above does not need an
assertion. */
if (p)
return j + 1;
}
}
else
{
j = *p - 3;
/* This should be folded to if (0), because p has just been
dereferenced. But we were not inserting enough ASSERT_EXPRs
to figure it out. */
if (!p)
return j - 4;
}
return i;
}
/* Target with fno-delete-null-pointer-checks should not fold checks */
/* { dg-final { scan-tree-dump-times "Folding predicate p_.*to 1" 1 "vrp1" } } */
/* { dg-final { scan-tree-dump-times "Folding predicate p_.*to 0" 1 "vrp1" { target { ! keeps_null_pointer_checks } } } } */
/* { dg-final { scan-tree-dump-times "Folding predicate p_.*to 0" 0 "vrp1" { target { keeps_null_pointer_checks } } } } */
/* { dg-final { scan-tree-dump-times "PREDICATE: p_\[0-9\]" 2 "vrp1" { target { ! keeps_null_pointer_checks } } } } */
/* { dg-final { scan-tree-dump-times "PREDICATE: p_\[0-9\]" 1 "vrp1" { target { keeps_null_pointer_checks } } } } */
/* { dg-final { cleanup-tree-dump "vrp1" } } */
|