diff options
author | Martin Sebor <msebor@redhat.com> | 2018-05-29 18:29:04 +0000 |
---|---|---|
committer | Martin Sebor <msebor@gcc.gnu.org> | 2018-05-29 12:29:04 -0600 |
commit | 72930d9f29c982dea8e5a219ad1baaf3f6d9c750 (patch) | |
tree | b801e96e27ee0c35deabfc849676b29dbfe305eb /gcc | |
parent | 009bb506b1a01ceff3ddf0f17a78c381891dfa64 (diff) | |
download | gcc-72930d9f29c982dea8e5a219ad1baaf3f6d9c750.zip gcc-72930d9f29c982dea8e5a219ad1baaf3f6d9c750.tar.gz gcc-72930d9f29c982dea8e5a219ad1baaf3f6d9c750.tar.bz2 |
PR middle-end/85888 - New test case c-c++-common/attr-nonstring-6.c from r260541 fails with excess errors
2018-05-29 Martin Sebor <msebor@redhat.com>
Richard Biener <rguenther@suse.de>
PR testsuite/85888
* calls.c (get_size_range): Call determine_value_range instead
of get_value_range..
* tree-vrp.h (determine_value_range): Declared new function.
* tree-vrp.c (determine_value_range_1, determine_value_range): New.
Co-Authored-By: Richard Biener <rguenther@suse.de>
From-SVN: r260902
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/calls.c | 4 | ||||
-rw-r--r-- | gcc/tree-vrp.c | 59 | ||||
-rw-r--r-- | gcc/tree-vrp.h | 2 |
4 files changed, 71 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ccf3b28..31144af 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2018-05-29 Martin Sebor <msebor@redhat.com> + Richard Biener <rguenther@suse.de> + + PR testsuite/85888 + * calls.c (get_size_range): Call determine_value_range instead + of get_value_range.. + * tree-vrp.h (determine_value_range): Declared new function. + * tree-vrp.c (determine_value_range_1, determine_value_range): New. + 2018-05-29 Richard Biener <rguenther@suse.de> * tree-vect-data-refs.c (vect_preserves_scalar_order_p): Make diff --git a/gcc/calls.c b/gcc/calls.c index 35bcff7..1f2cde6 100644 --- a/gcc/calls.c +++ b/gcc/calls.c @@ -1319,8 +1319,8 @@ get_size_range (tree exp, tree range[2], bool allow_zero /* = false */) wide_int min, max; enum value_range_type range_type; - if (TREE_CODE (exp) == SSA_NAME && integral) - range_type = get_range_info (exp, &min, &max); + if (integral) + range_type = determine_value_range (exp, &min, &max); else range_type = VR_VARYING; diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 6c482dd..fad25ed 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -7130,3 +7130,62 @@ make_pass_vrp (gcc::context *ctxt) { return new pass_vrp (ctxt); } + + +/* Worker for determine_value_range. */ + +static void +determine_value_range_1 (value_range *vr, tree expr) +{ + if (BINARY_CLASS_P (expr)) + { + value_range vr0 = VR_INITIALIZER, vr1 = VR_INITIALIZER; + determine_value_range_1 (&vr0, TREE_OPERAND (expr, 0)); + determine_value_range_1 (&vr1, TREE_OPERAND (expr, 1)); + extract_range_from_binary_expr_1 (vr, TREE_CODE (expr), TREE_TYPE (expr), + &vr0, &vr1); + } + else if (UNARY_CLASS_P (expr)) + { + value_range vr0 = VR_INITIALIZER; + determine_value_range_1 (&vr0, TREE_OPERAND (expr, 0)); + extract_range_from_unary_expr (vr, TREE_CODE (expr), TREE_TYPE (expr), + &vr0, TREE_TYPE (TREE_OPERAND (expr, 0))); + } + else if (TREE_CODE (expr) == INTEGER_CST) + set_value_range_to_value (vr, expr, NULL); + else + { + value_range_type kind; + wide_int min, max; + /* For SSA names try to extract range info computed by VRP. Otherwise + fall back to varying. */ + if (TREE_CODE (expr) == SSA_NAME + && INTEGRAL_TYPE_P (TREE_TYPE (expr)) + && (kind = get_range_info (expr, &min, &max)) != VR_VARYING) + set_value_range (vr, kind, wide_int_to_tree (TREE_TYPE (expr), min), + wide_int_to_tree (TREE_TYPE (expr), max), NULL); + else + set_value_range_to_varying (vr); + } +} + +/* Compute a value-range for EXPR and set it in *MIN and *MAX. Return + the determined range type. */ + +value_range_type +determine_value_range (tree expr, wide_int *min, wide_int *max) +{ + value_range vr = VR_INITIALIZER; + determine_value_range_1 (&vr, expr); + if ((vr.type == VR_RANGE + || vr.type == VR_ANTI_RANGE) + && !symbolic_range_p (&vr)) + { + *min = wi::to_wide (vr.min); + *max = wi::to_wide (vr.max); + return vr.type; + } + + return VR_VARYING; +} diff --git a/gcc/tree-vrp.h b/gcc/tree-vrp.h index d8f60be..608ca56 100644 --- a/gcc/tree-vrp.h +++ b/gcc/tree-vrp.h @@ -119,7 +119,7 @@ extern bool range_int_cst_singleton_p (value_range *); extern int value_inside_range (tree, tree, tree); extern tree get_single_symbol (tree, bool *, tree *); extern void maybe_set_nonzero_bits (edge, tree); - +extern value_range_type determine_value_range (tree, wide_int *, wide_int *); struct switch_update { gswitch *stmt; |