diff options
Diffstat (limited to 'gcc/tree-vrp.c')
-rw-r--r-- | gcc/tree-vrp.c | 47 |
1 files changed, 26 insertions, 21 deletions
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index c005c53c902..2103e1b61bb 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -243,9 +243,7 @@ supports_overflow_infinity (const_tree type) static inline tree make_overflow_infinity (tree val) { -#ifdef ENABLE_CHECKING - gcc_assert (val != NULL_TREE && CONSTANT_CLASS_P (val)); -#endif + gcc_checking_assert (val != NULL_TREE && CONSTANT_CLASS_P (val)); val = copy_node (val); TREE_OVERFLOW (val) = 1; return val; @@ -256,9 +254,7 @@ make_overflow_infinity (tree val) static inline tree negative_overflow_infinity (tree type) { -#ifdef ENABLE_CHECKING - gcc_assert (supports_overflow_infinity (type)); -#endif + gcc_checking_assert (supports_overflow_infinity (type)); return make_overflow_infinity (vrp_val_min (type)); } @@ -267,9 +263,7 @@ negative_overflow_infinity (tree type) static inline tree positive_overflow_infinity (tree type) { -#ifdef ENABLE_CHECKING - gcc_assert (supports_overflow_infinity (type)); -#endif + gcc_checking_assert (supports_overflow_infinity (type)); return make_overflow_infinity (vrp_val_max (type)); } @@ -332,9 +326,7 @@ avoid_overflow_infinity (tree val) return vrp_val_max (TREE_TYPE (val)); else { -#ifdef ENABLE_CHECKING - gcc_assert (vrp_val_is_min (val)); -#endif + gcc_checking_assert (vrp_val_is_min (val)); return vrp_val_min (TREE_TYPE (val)); } } @@ -2464,6 +2456,22 @@ extract_range_from_binary_expr (value_range_t *vr, } } + /* For divisions, if flag_non_call_exceptions is true, we must + not eliminate a division by zero. */ + if ((code == TRUNC_DIV_EXPR + || code == FLOOR_DIV_EXPR + || code == CEIL_DIV_EXPR + || code == EXACT_DIV_EXPR + || code == ROUND_DIV_EXPR) + && cfun->can_throw_non_call_exceptions + && (vr1.type != VR_RANGE + || symbolic_range_p (&vr1) + || range_includes_zero_p (&vr1))) + { + set_value_range_to_varying (vr); + return; + } + /* For divisions, if op0 is VR_RANGE, we can deduce a range even if op1 is VR_VARYING, VR_ANTI_RANGE, symbolic or can include 0. */ @@ -4131,13 +4139,11 @@ register_new_assert_for (tree name, tree expr, assert_locus_t n, loc, last_loc; basic_block dest_bb; -#if defined ENABLE_CHECKING - gcc_assert (bb == NULL || e == NULL); + gcc_checking_assert (bb == NULL || e == NULL); if (e == NULL) - gcc_assert (gimple_code (gsi_stmt (si)) != GIMPLE_COND - && gimple_code (gsi_stmt (si)) != GIMPLE_SWITCH); -#endif + gcc_checking_assert (gimple_code (gsi_stmt (si)) != GIMPLE_COND + && gimple_code (gsi_stmt (si)) != GIMPLE_SWITCH); /* Never build an assert comparing against an integer constant with TREE_OVERFLOW set. This confuses our undefined overflow warning @@ -5059,10 +5065,9 @@ process_assert_insertions_for (tree name, assert_locus_t loc) { /* We have been asked to insert the assertion on an edge. This is used only by COND_EXPR and SWITCH_EXPR assertions. */ -#if defined ENABLE_CHECKING - gcc_assert (gimple_code (gsi_stmt (loc->si)) == GIMPLE_COND - || gimple_code (gsi_stmt (loc->si)) == GIMPLE_SWITCH); -#endif + gcc_checking_assert (gimple_code (gsi_stmt (loc->si)) == GIMPLE_COND + || (gimple_code (gsi_stmt (loc->si)) + == GIMPLE_SWITCH)); gsi_insert_on_edge (loc->e, assert_stmt); return true; |