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(-)
@@ -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" } } */
@@ -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