diff options
author | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-05-07 13:31:00 +0000 |
---|---|---|
committer | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-05-07 13:31:00 +0000 |
commit | 0e443ce1f6d2a13241faf503b82696f6ba66e892 (patch) | |
tree | b20b7dea8ea2b3e8146eed68b755b81ed224d16c /gcc/tree-vrp.c | |
parent | 12790848b0033d3c89492c7040d3cc99ddb5fc90 (diff) | |
download | gcc-0e443ce1f6d2a13241faf503b82696f6ba66e892.tar.gz |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@187240 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-vrp.c')
-rw-r--r-- | gcc/tree-vrp.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 90660967c27..72c647fca4a 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; |