From: Martin Sebor Date: Tue, 29 May 2018 18:29:04 +0000 (+0000) Subject: PR middle-end/85888 - New test case c-c++-common/attr-nonstring-6.c from r260541... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=72930d9f29c982dea8e5a219ad1baaf3f6d9c750;p=gcc.git 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 Richard Biener 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 From-SVN: r260902 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ccf3b28d275..31144af9672 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2018-05-29 Martin Sebor + Richard Biener + + 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 * tree-vect-data-refs.c (vect_preserves_scalar_order_p): Make diff --git a/gcc/calls.c b/gcc/calls.c index 35bcff7c6e5..1f2cde696ec 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 6c482dd3e46..fad25ed2e33 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 d8f60be2311..608ca5658b5 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;