Commit f7503699 by Kugan Vivekanandarajah Committed by Kugan Vivekanandarajah

ADDR_EXPR and nonnull

ADDR_EXPR and nonnull
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.

From-SVN: r241428
parent e597e053
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):
......
......@@ -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;
......
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.
......
/* { 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" } } */
/* { 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" } } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment