aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorKugan Vivekanandarajah <kuganv@linaro.org>2016-10-21 20:13:55 +0000
committerKugan Vivekanandarajah <kugan@gcc.gnu.org>2016-10-21 20:13:55 +0000
commitf75036994f9d6945265d02cb29de502d6d7d538d (patch)
treecb421f8cf6590fce9a7ae6c57b2f3ba94212cd4b /gcc
parente597e0533d69081e6d6b01ca19f2924c1b8307ff (diff)
downloadgcc-f75036994f9d6945265d02cb29de502d6d7d538d.zip
gcc-f75036994f9d6945265d02cb29de502d6d7d538d.tar.gz
gcc-f75036994f9d6945265d02cb29de502d6d7d538d.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/ipa-prop.c8
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/ipa/vrp5.c34
-rw-r--r--gcc/testsuite/gcc.dg/ipa/vrp6.c34
5 files changed, 86 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index a2f8641..fd28129 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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):
diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c
index 353b638..1629870 100644
--- a/gcc/ipa-prop.c
+++ b/gcc/ipa-prop.c
@@ -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;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 2a67241..62aa521 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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.
diff --git a/gcc/testsuite/gcc.dg/ipa/vrp5.c b/gcc/testsuite/gcc.dg/ipa/vrp5.c
new file mode 100644
index 0000000..571798d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/vrp5.c
@@ -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" } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/vrp6.c b/gcc/testsuite/gcc.dg/ipa/vrp6.c
new file mode 100644
index 0000000..971db44
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/vrp6.c
@@ -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" } } */