aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-vrp.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2012-05-07 15:31:00 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2012-05-07 15:31:00 +0200
commit7a04f01cb7752b4c9fab847cbb6775e4b020f6d9 (patch)
treeb20b7dea8ea2b3e8146eed68b755b81ed224d16c /gcc/tree-vrp.c
parent4f22d4300fa45bd54c3ff48296f9d085c7a7a3eb (diff)
downloadgcc-7a04f01cb7752b4c9fab847cbb6775e4b020f6d9.zip
gcc-7a04f01cb7752b4c9fab847cbb6775e4b020f6d9.tar.gz
gcc-7a04f01cb7752b4c9fab847cbb6775e4b020f6d9.tar.bz2
re PR tree-optimization/53239 (VRP vs named value return opt)
PR tree-optimization/53239 * tree-vrp.c (get_value_range): Set VR of SSA_NAME_IS_DEFAULT_DEF of DECL_BY_REFERENCE RESULT_DECL to nonnull. * g++.dg/opt/vrp3.C: New test. * g++.dg/opt/vrp3-aux.cc: New file. * g++.dg/opt/vrp3.h: New file. From-SVN: r187240
Diffstat (limited to 'gcc/tree-vrp.c')
-rw-r--r--gcc/tree-vrp.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index 9066096..72c647f 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -695,17 +695,22 @@ get_value_range (const_tree var)
/* If VAR is a default definition of a parameter, the variable can
take any value in VAR's type. */
sym = SSA_NAME_VAR (var);
- if (SSA_NAME_IS_DEFAULT_DEF (var)
- && 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
- default definitions of PARM_DECLs. */
- if (POINTER_TYPE_P (TREE_TYPE (sym))
- && nonnull_arg_p (sym))
+ if (SSA_NAME_IS_DEFAULT_DEF (var))
+ {
+ 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
+ default definitions of PARM_DECLs. */
+ if (POINTER_TYPE_P (TREE_TYPE (sym))
+ && nonnull_arg_p (sym))
+ set_value_range_to_nonnull (vr, TREE_TYPE (sym));
+ else
+ set_value_range_to_varying (vr);
+ }
+ else if (TREE_CODE (sym) == RESULT_DECL
+ && DECL_BY_REFERENCE (sym))
set_value_range_to_nonnull (vr, TREE_TYPE (sym));
- else
- set_value_range_to_varying (vr);
}
return vr;