Hi, This patch uses get_ptr_nonnull in tree-vrp.
Bootstrapped and regression tested this with other patched without any new regressions on x86_64-linux-gnu. Is this OK for trunk? Thanks, Kugan gcc/testsuite/ChangeLog: 2016-10-12 Kugan Vivekanandarajah <kugan.vivekanandara...@linaro.org> * gcc.dg/ipa/vrp4.c: Adjust testcase. gcc/ChangeLog: 2016-10-12 Kugan Vivekanandarajah <kugan.vivekanandara...@linaro.org> * tree-vrp.c (get_value_range): Check get_ptr_nonnull.
>From 56e57ed72e44f22285d1f9de204ff8f98f6c08d2 Mon Sep 17 00:00:00 2001 From: Kugan Vivekanandarajah <kugan.vivekanandara...@linaro.org> Date: Wed, 12 Oct 2016 13:54:58 +1100 Subject: [PATCH 3/3] Teach-vrp-to-use-ptr-nonnull --- gcc/testsuite/gcc.dg/ipa/vrp4.c | 3 ++- gcc/tree-vrp.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/gcc/testsuite/gcc.dg/ipa/vrp4.c b/gcc/testsuite/gcc.dg/ipa/vrp4.c index d7e1f26..941f80e 100644 --- a/gcc/testsuite/gcc.dg/ipa/vrp4.c +++ b/gcc/testsuite/gcc.dg/ipa/vrp4.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-ipa-cp-details" } */ +/* { dg-options "-O2 -fdump-ipa-cp-details -fdump-tree-vrp1" } */ static __attribute__((noinline, noclone)) int foo (int *p) @@ -25,3 +25,4 @@ int bar (struct st *s) } /* { dg-final { scan-ipa-dump "Setting nonnull for 0" "cp" } } */ +/* { dg-final { scan-tree-dump-times "if" 1 "vrp1" } } */ diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 7e4f947..f9e5936 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -685,7 +685,8 @@ get_value_range (const_tree var) anti-ranges for pointers. Note that this is only valid with default definitions of PARM_DECLs. */ if (POINTER_TYPE_P (TREE_TYPE (sym)) - && nonnull_arg_p (sym)) + && (nonnull_arg_p (sym) + || get_ptr_nonnull (var))) set_value_range_to_nonnull (vr, TREE_TYPE (sym)); else if (INTEGRAL_TYPE_P (TREE_TYPE (sym))) { -- 2.7.4