aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimple-fold.c
diff options
context:
space:
mode:
authorAldy Hernandez <aldyh@redhat.com>2018-11-09 09:52:32 +0000
committerAldy Hernandez <aldyh@gcc.gnu.org>2018-11-09 09:52:32 +0000
commitc89af696c372d94688b06618a226ed49235ad212 (patch)
treee5607fc7bf18b658cf1c1f072b529f36de8df0d0 /gcc/gimple-fold.c
parent15e109b35dd461f2d6af85b861c4c71ea4478cb4 (diff)
downloadgcc-c89af696c372d94688b06618a226ed49235ad212.zip
gcc-c89af696c372d94688b06618a226ed49235ad212.tar.gz
gcc-c89af696c372d94688b06618a226ed49235ad212.tar.bz2
gimple-fold.c (size_must_be_zero_p): Use value_range API instead of performing ad-hoc calculations.
* gimple-fold.c (size_must_be_zero_p): Use value_range API instead of performing ad-hoc calculations. * tree-ssanames.c (set_range_info): New overloaded function accepting value_range &. (get_range_info): Same. * tree-ssanames.h (set_range_info_raw): Remove. (set_range_info): New prototype. (get_range_info): Same. * tree-vrp.h (value_range::null_p): Rename to zero_p. * tree-vrp.c (value_range::null_p): Same. From-SVN: r265952
Diffstat (limited to 'gcc/gimple-fold.c')
-rw-r--r--gcc/gimple-fold.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c
index 5468b60..67c8cfa 100644
--- a/gcc/gimple-fold.c
+++ b/gcc/gimple-fold.c
@@ -635,9 +635,8 @@ var_decl_component_p (tree var)
&& TREE_CODE (TREE_OPERAND (inner, 0)) == ADDR_EXPR));
}
-/* If the SIZE argument representing the size of an object is in a range
- of values of which exactly one is valid (and that is zero), return
- true, otherwise false. */
+/* Return TRUE if the SIZE argument, representing the size of an
+ object, is in a range of values of which exactly zero is valid. */
static bool
size_must_be_zero_p (tree size)
@@ -648,21 +647,19 @@ size_must_be_zero_p (tree size)
if (TREE_CODE (size) != SSA_NAME || !INTEGRAL_TYPE_P (TREE_TYPE (size)))
return false;
- wide_int min, max;
- enum value_range_kind rtype = get_range_info (size, &min, &max);
- if (rtype != VR_ANTI_RANGE)
- return false;
-
tree type = TREE_TYPE (size);
int prec = TYPE_PRECISION (type);
- wide_int wone = wi::one (prec);
-
/* Compute the value of SSIZE_MAX, the largest positive value that
can be stored in ssize_t, the signed counterpart of size_t. */
wide_int ssize_max = wi::lshift (wi::one (prec), prec - 1) - 1;
-
- return wi::eq_p (min, wone) && wi::geu_p (max, ssize_max);
+ value_range valid_range (VR_RANGE,
+ build_int_cst (type, 0),
+ wide_int_to_tree (type, ssize_max));
+ value_range vr;
+ get_range_info (size, vr);
+ vr.intersect (&valid_range);
+ return vr.zero_p ();
}
/* Fold function call to builtin mem{{,p}cpy,move}. Try to detect and