diff mbox

[vrp] use get_ptr_nonnull in tree-vrp

Message ID 5162069f-bb7a-c3f3-cd6d-183d5bbf32c9@linaro.org
State New
Headers show

Commit Message

Kugan Vivekanandarajah Oct. 13, 2016, 4:38 a.m. UTC
Hi Richard,


On 13/10/16 05:53, kugan wrote:
> Hi Richard,

>

> On 12/10/16 23:24, Richard Biener wrote:

>> On Wed, Oct 12, 2016 at 8:56 AM, kugan

>> <kugan.vivekanandarajah@linaro.org> wrote:

>>> 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?

>>

>> Um.  Doesn't make much sense given nothing provides this info before EVRP?

>> And if it makes sense then it makes sense not only for PARM_DECL SSA names.

> Not before EVRP. But when in TREE-VRP, EVRP + IPA-VRP should provide this.


My primary intention was to pass it for PARM_DECL SSA names which comes 
from ipa-vrp. I have changed this now.

Thanks,
Kugan

> I am not sure if this is the question?

>

> Thanks,

> Kugan

>>

>> Richard.

>>

>>> Thanks,

>>> Kugan

>>>

>>> gcc/testsuite/ChangeLog:

>>>

>>> 2016-10-12  Kugan Vivekanandarajah  <kugan.vivekanandarajah@linaro.org>

>>>

>>>         * gcc.dg/ipa/vrp4.c: Adjust testcase.

>>>

>>> gcc/ChangeLog:

>>>

>>> 2016-10-12  Kugan Vivekanandarajah  <kugan.vivekanandarajah@linaro.org>

>>>

>>>         * tree-vrp.c (get_value_range): Check get_ptr_nonnull.
diff mbox

Patch

From c033af7161bcf54f50262688854cb32e3e8eeb54 Mon Sep 17 00:00:00 2001
From: Kugan Vivekanandarajah <kugan.vivekanandarajah@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                  | 5 ++++-
 2 files changed, 6 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..bc53d07 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -679,7 +679,10 @@  get_value_range (const_tree var)
   if (SSA_NAME_IS_DEFAULT_DEF (var))
     {
       sym = SSA_NAME_VAR (var);
-      if (TREE_CODE (sym) == PARM_DECL)
+      if (POINTER_TYPE_P (TREE_TYPE (sym))
+	  && get_ptr_nonnull (var))
+	set_value_range_to_nonnull (vr, TREE_TYPE (sym));
+      else if (TREE_CODE (sym) == PARM_DECL)
 	{
 	  /* Try to use the "nonnull" attribute to create ~[0, 0]
 	     anti-ranges for pointers.  Note that this is only valid with
-- 
2.7.4