Skip to content

Commit

Permalink
ADDR_EXPR and nonnull
Browse files Browse the repository at this point in the history
gcc/ChangeLog:

2016-10-21  Kugan Vivekanandarajah  <kuganv@linaro.org>

	* ipa-prop.c (ipa_compute_jump_functions_for_edge): Create nonzero
	value range for pointers in more cases.

gcc/testsuite/ChangeLog:

2016-10-21  Kugan Vivekanandarajah  <kuganv@linaro.org>

	* gcc.dg/ipa/vrp5.c: New test.
	* gcc.dg/ipa/vrp6.c: New test.




git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@241428 138bc75d-0d04-0410-961f-82ee72b054a4
  • Loading branch information
kugan committed Oct 21, 2016
1 parent e318c42 commit 6cb5d05
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 0 deletions.
5 changes: 5 additions & 0 deletions gcc/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2016-10-21 Kugan Vivekanandarajah <kuganv@linaro.org>

* ipa-prop.c (ipa_compute_jump_functions_for_edge): Create nonzero
value range for pointers in more cases.

2016-10-21 Wilco Dijkstra <wdijkstr@arm.com>

* config/aarch64/aarch64.c (aarch64_add_constant_internal):
Expand Down
8 changes: 8 additions & 0 deletions gcc/ipa-prop.c
Original file line number Diff line number Diff line change
Expand Up @@ -1670,9 +1670,17 @@ ipa_compute_jump_functions_for_edge (struct ipa_func_body_info *fbi,

if (POINTER_TYPE_P (TREE_TYPE (arg)))
{
bool addr_nonzero = false;
bool strict_overflow = false;

if (TREE_CODE (arg) == SSA_NAME
&& param_type
&& get_ptr_nonnull (arg))
addr_nonzero = true;
else if (tree_single_nonzero_warnv_p (arg, &strict_overflow))
addr_nonzero = true;

if (addr_nonzero)
{
jfunc->vr_known = true;
jfunc->m_vr.type = VR_ANTI_RANGE;
Expand Down
5 changes: 5 additions & 0 deletions gcc/testsuite/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2016-10-21 Kugan Vivekanandarajah <kuganv@linaro.org>

* gcc.dg/ipa/vrp5.c: New test.
* gcc.dg/ipa/vrp6.c: New test.

2016-10-21 Wilco Dijkstra <wdijkstr@arm.com>

* gcc.target/aarch64/test_frame_17.c: New test.
Expand Down
34 changes: 34 additions & 0 deletions gcc/testsuite/gcc.dg/ipa/vrp5.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-ipa-cp-details -fdump-tree-vrp1" } */

static __attribute__((noinline, noclone))
int foo (int *p)
{
if (!p)
return 0;
*p = 1;
}

struct st
{
int a;
int b;
};

int arr1[10];
int a;
int bar (struct st *s)
{
int arr2[10];
int b;
if (!s)
return 0;
foo (&s->a);
foo (&a);
foo (&b);
foo (&arr1[1]);
foo (&arr2[1]);
}

/* { dg-final { scan-ipa-dump "Setting nonnull for 0" "cp" } } */
/* { dg-final { scan-tree-dump-times "if" 1 "vrp1" } } */
34 changes: 34 additions & 0 deletions gcc/testsuite/gcc.dg/ipa/vrp6.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-ipa-cp-details -fdump-tree-vrp1" } */

static __attribute__((noinline, noclone))
int foo (int *p)
{
if (!p)
return 0;
*p = 1;
}

struct st
{
int a;
int b;
};

struct st s2;
int a;
int bar (struct st *s)
{
struct st s3;
int b;
if (!s)
return 0;
foo (&s->a);
foo (&s2.a);
foo (&s3.a);
foo (&a);
foo (&b);
}

/* { dg-final { scan-ipa-dump "Setting nonnull for 0" "cp" } } */
/* { dg-final { scan-tree-dump-times "if" 1 "vrp1" } } */

0 comments on commit 6cb5d05

Please sign in to comment.