diff options
-rw-r--r-- | gcc/ChangeLog | 13 | ||||
-rw-r--r-- | gcc/gimplify.c | 4 | ||||
-rw-r--r-- | gcc/tree-vrp.c | 37 | ||||
-rw-r--r-- | gcc/tree.c | 19 | ||||
-rw-r--r-- | gcc/tree.h | 1 |
5 files changed, 53 insertions, 21 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9192b78..c211db0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,16 @@ +2013-11-06 Richard Biener <rguenther@suse.de> + + * tree.c (drop_tree_overflow): New function. + * tree.h (drop_tree_overflow): Declare. + * gimplify.c (gimplify_expr): Drop TREE_OVERFLOW. + * tree-vrp.c (range_int_cst_singleton_p): Use + is_overflow_infinity instead of testing TREE_OVERFLOW. + (extract_range_from_assert): Likewise. + (zero_nonzero_bits_from_vr): Likewise. + (extract_range_basic): Likewise. + (register_new_assert_for): Use drop_tree_overflow. + (vrp_visit_phi_node): Likewise. + 2013-11-06 Dodji Seketeli <dodji@redhat.com> preprocessor/58580 diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 4df9ed4..721e8fb 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -7897,6 +7897,10 @@ gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, case STRING_CST: case COMPLEX_CST: case VECTOR_CST: + /* Drop the overflow flag on constants, we do not want + that in the GIMPLE IL. */ + if (TREE_OVERFLOW_P (*expr_p)) + *expr_p = drop_tree_overflow (*expr_p); ret = GS_ALL_DONE; break; diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 2a90430..9b26f17 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -892,8 +892,8 @@ static inline bool range_int_cst_singleton_p (value_range_t *vr) { return (range_int_cst_p (vr) - && !TREE_OVERFLOW (vr->min) - && !TREE_OVERFLOW (vr->max) + && !is_overflow_infinity (vr->min) + && !is_overflow_infinity (vr->max) && tree_int_cst_equal (vr->min, vr->max)); } @@ -1741,7 +1741,7 @@ extract_range_from_assert (value_range_t *vr_p, tree expr) all should be optimized away above us. */ if ((cond_code == LT_EXPR && compare_values (max, min) == 0) - || (CONSTANT_CLASS_P (max) && TREE_OVERFLOW (max))) + || is_overflow_infinity (max)) set_value_range_to_varying (vr_p); else { @@ -1781,7 +1781,7 @@ extract_range_from_assert (value_range_t *vr_p, tree expr) all should be optimized away above us. */ if ((cond_code == GT_EXPR && compare_values (min, max) == 0) - || (CONSTANT_CLASS_P (min) && TREE_OVERFLOW (min))) + || is_overflow_infinity (min)) set_value_range_to_varying (vr_p); else { @@ -1998,8 +1998,8 @@ zero_nonzero_bits_from_vr (value_range_t *vr, *may_be_nonzero = double_int_minus_one; *must_be_nonzero = double_int_zero; if (!range_int_cst_p (vr) - || TREE_OVERFLOW (vr->min) - || TREE_OVERFLOW (vr->max)) + || is_overflow_infinity (vr->min) + || is_overflow_infinity (vr->max)) return false; if (range_int_cst_singleton_p (vr)) @@ -3623,13 +3623,13 @@ extract_range_basic (value_range_t *vr, gimple stmt) && integer_nonzerop (vr0->min)) || (vr0->type == VR_ANTI_RANGE && integer_zerop (vr0->min))) - && !TREE_OVERFLOW (vr0->min)) + && !is_overflow_infinity (vr0->min)) mini = 1; /* If some high bits are known to be zero, we can decrease the maximum. */ if (vr0->type == VR_RANGE && TREE_CODE (vr0->max) == INTEGER_CST - && !TREE_OVERFLOW (vr0->max)) + && !is_overflow_infinity (vr0->max)) maxi = tree_floor_log2 (vr0->max) + 1; } goto bitop_builtin; @@ -3664,7 +3664,7 @@ extract_range_basic (value_range_t *vr, gimple stmt) result maximum. */ if (vr0->type == VR_RANGE && TREE_CODE (vr0->min) == INTEGER_CST - && !TREE_OVERFLOW (vr0->min)) + && !is_overflow_infinity (vr0->min)) { maxi = prec - 1 - tree_floor_log2 (vr0->min); if (maxi != prec) @@ -3672,7 +3672,7 @@ extract_range_basic (value_range_t *vr, gimple stmt) } else if (vr0->type == VR_ANTI_RANGE && integer_zerop (vr0->min) - && !TREE_OVERFLOW (vr0->min)) + && !is_overflow_infinity (vr0->min)) { maxi = prec - 1; mini = 0; @@ -3683,7 +3683,7 @@ extract_range_basic (value_range_t *vr, gimple stmt) result minimum. */ if (vr0->type == VR_RANGE && TREE_CODE (vr0->max) == INTEGER_CST - && !TREE_OVERFLOW (vr0->max)) + && !is_overflow_infinity (vr0->max)) { mini = prec - 1 - tree_floor_log2 (vr0->max); if (mini == prec) @@ -3726,7 +3726,7 @@ extract_range_basic (value_range_t *vr, gimple stmt) && integer_nonzerop (vr0->min)) || (vr0->type == VR_ANTI_RANGE && integer_zerop (vr0->min))) - && !TREE_OVERFLOW (vr0->min)) + && !is_overflow_infinity (vr0->min)) { mini = 0; maxi = prec - 1; @@ -3735,7 +3735,7 @@ extract_range_basic (value_range_t *vr, gimple stmt) we can decrease the result maximum. */ if (vr0->type == VR_RANGE && TREE_CODE (vr0->max) == INTEGER_CST - && !TREE_OVERFLOW (vr0->max)) + && !is_overflow_infinity (vr0->max)) { maxi = tree_floor_log2 (vr0->max); /* For vr0 [0, 0] give up. */ @@ -4619,10 +4619,8 @@ register_new_assert_for (tree name, tree expr, /* Never build an assert comparing against an integer constant with TREE_OVERFLOW set. This confuses our undefined overflow warning machinery. */ - if (TREE_CODE (val) == INTEGER_CST - && TREE_OVERFLOW (val)) - val = build_int_cst_wide (TREE_TYPE (val), - TREE_INT_CST_LOW (val), TREE_INT_CST_HIGH (val)); + if (TREE_OVERFLOW_P (val)) + val = drop_tree_overflow (val); /* The new assertion A will be inserted at BB or E. We need to determine if the new location is dominated by a previously @@ -8320,10 +8318,7 @@ vrp_visit_phi_node (gimple phi) else { if (is_overflow_infinity (arg)) - { - arg = copy_node (arg); - TREE_OVERFLOW (arg) = 0; - } + arg = drop_tree_overflow (arg); vr_arg.type = VR_RANGE; vr_arg.min = arg; @@ -12542,4 +12542,23 @@ get_tree_code_name (enum tree_code code) return tree_code_name[code]; } +/* Drops the TREE_OVERFLOW flag from T. */ + +tree +drop_tree_overflow (tree t) +{ + gcc_checking_assert (TREE_OVERFLOW (t)); + + /* For tree codes with a sharing machinery re-build the result. */ + if (TREE_CODE (t) == INTEGER_CST) + return build_int_cst_wide (TREE_TYPE (t), + TREE_INT_CST_LOW (t), TREE_INT_CST_HIGH (t)); + + /* Otherwise, as all tcc_constants are possibly shared, copy the node + and drop the flag. */ + t = copy_node (t); + TREE_OVERFLOW (t) = 0; + return t; +} + #include "gt-tree.h" @@ -4800,6 +4800,7 @@ extern tree get_base_address (tree t); extern void mark_addressable (tree); /* In tree.c. */ +extern tree drop_tree_overflow (tree); extern int tree_map_base_eq (const void *, const void *); extern unsigned int tree_map_base_hash (const void *); extern int tree_map_base_marked_p (const void *); |