Re: [vrp] use get_ptr_nonnull in tree-vrp

2016-10-13 Thread Richard Biener
On Thu, Oct 13, 2016 at 6:38 AM, kugan
 wrote:
> 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
>>>  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.

Ok I see.  The new patch still has it inside the SSA_NAME_IS_DEFAULT_DEF () if
so isn't any better in this regard.  To handle non-default-defs you'd
have to intersect
with non-NULL in update_value_range where we also intersect with get_range_info
info for integer types.

Your original patch was better so that is ok (once the prerequesites
are approved).

We can decide later if it's worth handling get_ptr_nonnull in
update_value_range.

Thanks,
Richard.

> Thanks,
> Kugan
>
>
>> I am not sure if this is the question?
>>
>> Thanks,
>> Kugan
>>>
>>>
>>> Richard.
>>>
 Thanks,
 Kugan

 gcc/testsuite/ChangeLog:

 2016-10-12  Kugan Vivekanandarajah  

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

 gcc/ChangeLog:

 2016-10-12  Kugan Vivekanandarajah  

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


Re: [vrp] use get_ptr_nonnull in tree-vrp

2016-10-12 Thread kugan

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

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

gcc/ChangeLog:

2016-10-12  Kugan Vivekanandarajah  

* tree-vrp.c (get_value_range): Check get_ptr_nonnull.
>From c033af7161bcf54f50262688854cb32e3e8eeb54 Mon Sep 17 00:00:00 2001
From: Kugan Vivekanandarajah 
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



Re: [vrp] use get_ptr_nonnull in tree-vrp

2016-10-12 Thread kugan

Hi Richard,

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

On Wed, Oct 12, 2016 at 8:56 AM, kugan
 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.

I am not sure if this is the question?

Thanks,
Kugan


Richard.


Thanks,
Kugan

gcc/testsuite/ChangeLog:

2016-10-12  Kugan Vivekanandarajah  

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

gcc/ChangeLog:

2016-10-12  Kugan Vivekanandarajah  

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


Re: [vrp] use get_ptr_nonnull in tree-vrp

2016-10-12 Thread Richard Biener
On Wed, Oct 12, 2016 at 8:56 AM, kugan
 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.

Richard.

> Thanks,
> Kugan
>
> gcc/testsuite/ChangeLog:
>
> 2016-10-12  Kugan Vivekanandarajah  
>
> * gcc.dg/ipa/vrp4.c: Adjust testcase.
>
> gcc/ChangeLog:
>
> 2016-10-12  Kugan Vivekanandarajah  
>
> * tree-vrp.c (get_value_range): Check get_ptr_nonnull.


[vrp] use get_ptr_nonnull in tree-vrp

2016-10-12 Thread kugan

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  

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

gcc/ChangeLog:

2016-10-12  Kugan Vivekanandarajah  

* tree-vrp.c (get_value_range): Check get_ptr_nonnull.
>From 56e57ed72e44f22285d1f9de204ff8f98f6c08d2 Mon Sep 17 00:00:00 2001
From: Kugan Vivekanandarajah 
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