diff options
author | Richard Biener <rguenther@suse.de> | 2021-07-16 14:53:42 +0200 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2021-07-19 07:59:43 +0200 |
commit | 4a21a8c34a707e88f450375e3c7d593be75162f4 (patch) | |
tree | e7bc4d81323b916aa15380088689036ea0111147 /gcc | |
parent | bdea84c4b5773723fa3ac7fa01f33542093864d5 (diff) | |
download | gcc-4a21a8c34a707e88f450375e3c7d593be75162f4.zip gcc-4a21a8c34a707e88f450375e3c7d593be75162f4.tar.gz gcc-4a21a8c34a707e88f450375e3c7d593be75162f4.tar.bz2 |
Remove gimple_expr_type uses from value-range code
This removes the last uses from value-range code.
2021-07-16 Richard Biener <rguenther@suse.de>
* tree-vrp.c (register_edge_assert_for_2): Use the
type from the LHS.
(vrp_folder::fold_predicate_in): Likewise.
* vr-values.c (gimple_assign_nonzero_p): Likewise.
(vr_values::extract_range_from_comparison): Likewise.
(vr_values::extract_range_from_ubsan_builtin): Use the
type of the first operand.
(vr_values::extract_range_basic): Push down type
computation, use the appropriate LHS.
(vr_values::extract_range_from_assignment): Use the
type of the LHS.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/tree-vrp.c | 14 | ||||
-rw-r--r-- | gcc/vr-values.c | 28 |
2 files changed, 23 insertions, 19 deletions
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 0565c9b..a9c31bc 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -1484,13 +1484,13 @@ register_edge_assert_for_2 (tree name, edge e, } /* Extract NAME2 from the (optional) sign-changing cast. */ - if (gimple_assign_cast_p (def_stmt)) + if (gassign *ass = dyn_cast <gassign *> (def_stmt)) { - if (CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (def_stmt)) - && ! TYPE_UNSIGNED (TREE_TYPE (gimple_assign_rhs1 (def_stmt))) - && (TYPE_PRECISION (gimple_expr_type (def_stmt)) - == TYPE_PRECISION (TREE_TYPE (gimple_assign_rhs1 (def_stmt))))) - name3 = gimple_assign_rhs1 (def_stmt); + if (CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (ass)) + && ! TYPE_UNSIGNED (TREE_TYPE (gimple_assign_rhs1 (ass))) + && (TYPE_PRECISION (TREE_TYPE (gimple_assign_lhs (ass))) + == TYPE_PRECISION (TREE_TYPE (gimple_assign_rhs1 (ass))))) + name3 = gimple_assign_rhs1 (ass); } /* If name3 is used later, create an ASSERT_EXPR for it. */ @@ -4119,7 +4119,7 @@ vrp_folder::fold_predicate_in (gimple_stmt_iterator *si) if (val) { if (assignment_p) - val = fold_convert (gimple_expr_type (stmt), val); + val = fold_convert (TREE_TYPE (gimple_assign_lhs (stmt)), val); if (dump_file) { diff --git a/gcc/vr-values.c b/gcc/vr-values.c index 190676d..1b3ec38 100644 --- a/gcc/vr-values.c +++ b/gcc/vr-values.c @@ -338,16 +338,17 @@ gimple_assign_nonzero_p (gimple *stmt) { enum tree_code code = gimple_assign_rhs_code (stmt); bool strict_overflow_p; + tree type = TREE_TYPE (gimple_assign_lhs (stmt)); switch (get_gimple_rhs_class (code)) { case GIMPLE_UNARY_RHS: return tree_unary_nonzero_warnv_p (gimple_assign_rhs_code (stmt), - gimple_expr_type (stmt), + type, gimple_assign_rhs1 (stmt), &strict_overflow_p); case GIMPLE_BINARY_RHS: return tree_binary_nonzero_warnv_p (gimple_assign_rhs_code (stmt), - gimple_expr_type (stmt), + type, gimple_assign_rhs1 (stmt), gimple_assign_rhs2 (stmt), &strict_overflow_p); @@ -1025,7 +1026,7 @@ vr_values::extract_range_from_comparison (value_range_equiv *vr, gimple *stmt) { enum tree_code code = gimple_assign_rhs_code (stmt); - tree type = gimple_expr_type (stmt); + tree type = TREE_TYPE (gimple_assign_lhs (stmt)); tree op0 = gimple_assign_rhs1 (stmt); tree op1 = gimple_assign_rhs2 (stmt); bool sop; @@ -1164,7 +1165,6 @@ bool vr_values::extract_range_from_ubsan_builtin (value_range_equiv *vr, gimple *stmt) { gcc_assert (is_gimple_call (stmt)); - tree type = gimple_expr_type (stmt); enum tree_code subcode = ERROR_MARK; combined_fn cfn = gimple_call_combined_fn (stmt); scalar_int_mode mode; @@ -1190,7 +1190,8 @@ vr_values::extract_range_from_ubsan_builtin (value_range_equiv *vr, gimple *stmt any overflow, we'll complain, but will actually do wrapping operation. */ flag_wrapv = 1; - extract_range_from_binary_expr (vr, subcode, type, + extract_range_from_binary_expr (vr, subcode, + TREE_TYPE (gimple_call_arg (stmt, 0)), gimple_call_arg (stmt, 0), gimple_call_arg (stmt, 1)); flag_wrapv = saved_flag_wrapv; @@ -1217,7 +1218,6 @@ void vr_values::extract_range_basic (value_range_equiv *vr, gimple *stmt) { bool sop; - tree type = gimple_expr_type (stmt); if (is_gimple_call (stmt)) { @@ -1244,13 +1244,14 @@ vr_values::extract_range_basic (value_range_equiv *vr, gimple *stmt) /* Handle extraction of the two results (result of arithmetics and a flag whether arithmetics overflowed) from {ADD,SUB,MUL}_OVERFLOW internal function. Similarly from ATOMIC_COMPARE_EXCHANGE. */ - else if (is_gimple_assign (stmt) - && (gimple_assign_rhs_code (stmt) == REALPART_EXPR - || gimple_assign_rhs_code (stmt) == IMAGPART_EXPR) - && INTEGRAL_TYPE_P (type)) + if (is_gimple_assign (stmt) + && (gimple_assign_rhs_code (stmt) == REALPART_EXPR + || gimple_assign_rhs_code (stmt) == IMAGPART_EXPR) + && INTEGRAL_TYPE_P (TREE_TYPE (gimple_assign_lhs (stmt)))) { enum tree_code code = gimple_assign_rhs_code (stmt); tree op = gimple_assign_rhs1 (stmt); + tree type = TREE_TYPE (gimple_assign_lhs (stmt)); if (TREE_CODE (op) == code && TREE_CODE (TREE_OPERAND (op, 0)) == SSA_NAME) { gimple *g = SSA_NAME_DEF_STMT (TREE_OPERAND (op, 0)); @@ -1328,6 +1329,9 @@ vr_values::extract_range_basic (value_range_equiv *vr, gimple *stmt) } } } + /* None of the below should need a 'type', but we are only called + for assignments and calls with a LHS. */ + tree type = TREE_TYPE (gimple_get_lhs (stmt)); if (INTEGRAL_TYPE_P (type) && gimple_stmt_nonnegative_warnv_p (stmt, &sop)) set_value_range_to_nonnegative (vr, type); @@ -1355,12 +1359,12 @@ vr_values::extract_range_from_assignment (value_range_equiv *vr, gassign *stmt) extract_range_from_ssa_name (vr, gimple_assign_rhs1 (stmt)); else if (TREE_CODE_CLASS (code) == tcc_binary) extract_range_from_binary_expr (vr, gimple_assign_rhs_code (stmt), - gimple_expr_type (stmt), + TREE_TYPE (gimple_assign_lhs (stmt)), gimple_assign_rhs1 (stmt), gimple_assign_rhs2 (stmt)); else if (TREE_CODE_CLASS (code) == tcc_unary) extract_range_from_unary_expr (vr, gimple_assign_rhs_code (stmt), - gimple_expr_type (stmt), + TREE_TYPE (gimple_assign_lhs (stmt)), gimple_assign_rhs1 (stmt)); else if (code == COND_EXPR) extract_range_from_cond_expr (vr, stmt); |