From: Nathan Sidwell Date: Tue, 11 Aug 2015 12:34:43 +0000 (+0000) Subject: * tree-vrp.c (simplify_abs_using_ranges): Simplify. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8299dd5cbb6fbb756f0ad2f4dbff31c549e00837;p=gcc.git * tree-vrp.c (simplify_abs_using_ranges): Simplify. From-SVN: r226779 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3a078162b35..cb2d6a06b9a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,7 @@ 2015-08-11 Nathan Sidwell + * tree-vrp.c (simplify_abs_using_ranges): Simplify. + * tree-ssa-phiopt.c (minmax_replacement): Create new ssa name if we're not the only contributor to target phi. diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 31a9d21b4ba..d51acaa52fc 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -9152,37 +9152,25 @@ simplify_div_or_mod_using_ranges (gimple stmt) static bool simplify_abs_using_ranges (gimple stmt) { - tree val = NULL; tree op = gimple_assign_rhs1 (stmt); - tree type = TREE_TYPE (op); value_range_t *vr = get_value_range (op); - if (TYPE_UNSIGNED (type)) - { - val = integer_zero_node; - } - else if (vr) + if (vr) { + tree val = NULL; bool sop = false; val = compare_range_with_value (LE_EXPR, vr, integer_zero_node, &sop); if (!val) { + /* The range is neither <= 0 nor > 0. Now see if it is + either < 0 or >= 0. */ sop = false; - val = compare_range_with_value (GE_EXPR, vr, integer_zero_node, + val = compare_range_with_value (LT_EXPR, vr, integer_zero_node, &sop); - - if (val) - { - if (integer_zerop (val)) - val = integer_one_node; - else if (integer_onep (val)) - val = integer_zero_node; - } } - if (val - && (integer_onep (val) || integer_zerop (val))) + if (val) { if (sop && issue_strict_overflow_warning (WARN_STRICT_OVERFLOW_MISC)) { @@ -9198,10 +9186,10 @@ simplify_abs_using_ranges (gimple stmt) } gimple_assign_set_rhs1 (stmt, op); - if (integer_onep (val)) - gimple_assign_set_rhs_code (stmt, NEGATE_EXPR); - else + if (integer_zerop (val)) gimple_assign_set_rhs_code (stmt, SSA_NAME); + else + gimple_assign_set_rhs_code (stmt, NEGATE_EXPR); update_stmt (stmt); return true; }