1 /* { dg-do compile } */
2 /* { dg-options "-O2 -fno-tree-fre -fdisable-tree-evrp -fdump-tree-vrp1-details -fdelete-null-pointer-checks" } */
3 
4 /* Compile with -fno-tree-fre -O2 to prevent CSEing *p.  */
5 int
foo(int a,int * p)6 foo (int a, int *p)
7 {
8   int x = *p + 2;
9   int y = *p - 1;
10   int z = *p + 9;
11 
12   /* This should be folded to if (1), but only one ASSERT_EXPR should
13      be inserted.  */
14   if (p)
15     a = x + y + z;
16   else
17     a = x - y;
18 
19   return a;
20 }
21 /* Target disabling -fdelete-null-pointer-checks should not fold checks */
22 /* { dg-final { scan-tree-dump-times "Folding predicate p_.*to 1" 1 "vrp1" { target { ! keeps_null_pointer_checks } } } } */
23 /* { dg-final { scan-tree-dump-times "PREDICATE: p_.* ne_expr 0" 1 "vrp1" { target { ! keeps_null_pointer_checks } } } } */
24 /* { dg-final { scan-tree-dump-times "Folding predicate p_.*to 1" 0 "vrp1" { target {   keeps_null_pointer_checks } } } } */
25