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