From: Richard Sandiford Date: Wed, 7 Aug 2019 13:18:35 +0000 (+0000) Subject: Make IPA predicate::size a poly_int64 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8600364582f24d2a3f227111c6a87b7d98561c69;p=gcc.git Make IPA predicate::size a poly_int64 This patch changes the IPA predicate::size field from a HOST_WIDE_INT to a poly_int64. 2019-08-07 Richard Sandiford gcc/ * data-streamer.h (streamer_write_poly_uint64): Declare. (streamer_read_poly_uint64): Likewise. * data-streamer-in.c (streamer_read_poly_uint64): New function. * data-streamer-out.c (streamer_write_poly_uint64): Likewise. * ipa-predicate.h (condition::size): Turn into a poly_int64. (add_condition): Take a poly_int64 size. * ipa-predicate.c (add_condition): Likewise. * ipa-prop.h (ipa_load_from_parm_agg): Take a poly_int64 size pointer. * ipa-prop.c (ipa_load_from_parm_agg): Likewise. (ipcp_modif_dom_walker::before_dom_children): Update accordingly. * ipa-fnsummary.c (evaluate_conditions_for_known_args): Handle condition::size as a poly_int64. (unmodified_parm_1): Take a poly_int64 size pointer. (unmodified_parm): Likewise. (unmodified_parm_or_parm_agg_item): Likewise. (set_cond_stmt_execution_predicate): Update accordingly. (set_switch_stmt_execution_predicate): Likewise. (will_be_nonconstant_expr_predicate): Likewise. (will_be_nonconstant_predicate): Likewise. (inline_read_section): Stream condition::size as a poly_int. (ipa_fn_summary_write): Likewise. From-SVN: r274162 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c80ab831022..a4b0c35f4ba 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,27 @@ +2019-08-07 Richard Sandiford + + * data-streamer.h (streamer_write_poly_uint64): Declare. + (streamer_read_poly_uint64): Likewise. + * data-streamer-in.c (streamer_read_poly_uint64): New function. + * data-streamer-out.c (streamer_write_poly_uint64): Likewise. + * ipa-predicate.h (condition::size): Turn into a poly_int64. + (add_condition): Take a poly_int64 size. + * ipa-predicate.c (add_condition): Likewise. + * ipa-prop.h (ipa_load_from_parm_agg): Take a poly_int64 size pointer. + * ipa-prop.c (ipa_load_from_parm_agg): Likewise. + (ipcp_modif_dom_walker::before_dom_children): Update accordingly. + * ipa-fnsummary.c (evaluate_conditions_for_known_args): Handle + condition::size as a poly_int64. + (unmodified_parm_1): Take a poly_int64 size pointer. + (unmodified_parm): Likewise. + (unmodified_parm_or_parm_agg_item): Likewise. + (set_cond_stmt_execution_predicate): Update accordingly. + (set_switch_stmt_execution_predicate): Likewise. + (will_be_nonconstant_expr_predicate): Likewise. + (will_be_nonconstant_predicate): Likewise. + (inline_read_section): Stream condition::size as a poly_int. + (ipa_fn_summary_write): Likewise. + 2019-08-07 Martin Liska * fold-const.c (twoval_comparison_p): Replace int diff --git a/gcc/data-streamer-in.c b/gcc/data-streamer-in.c index 11ad084780b..d9742d5334f 100644 --- a/gcc/data-streamer-in.c +++ b/gcc/data-streamer-in.c @@ -175,6 +175,17 @@ streamer_read_hwi (class lto_input_block *ib) } } +/* Read a poly_uint64 from IB. */ + +poly_uint64 +streamer_read_poly_uint64 (class lto_input_block *ib) +{ + poly_uint64 res; + for (unsigned int i = 0; i < NUM_POLY_INT_COEFFS; ++i) + res.coeffs[i] = streamer_read_uhwi (ib); + return res; +} + /* Read gcov_type value from IB. */ gcov_type diff --git a/gcc/data-streamer-out.c b/gcc/data-streamer-out.c index d058efd92c0..54d080ea8d9 100644 --- a/gcc/data-streamer-out.c +++ b/gcc/data-streamer-out.c @@ -220,6 +220,15 @@ streamer_write_hwi (struct output_block *ob, HOST_WIDE_INT work) streamer_write_hwi_stream (ob->main_stream, work); } +/* Write a poly_uint64 value WORK to OB->main_stream. */ + +void +streamer_write_poly_uint64 (struct output_block *ob, poly_uint64 work) +{ + for (int i = 0; i < NUM_POLY_INT_COEFFS; ++i) + streamer_write_uhwi_stream (ob->main_stream, work.coeffs[i]); +} + /* Write a gcov counter value WORK to OB->main_stream. */ void diff --git a/gcc/data-streamer.h b/gcc/data-streamer.h index c8bfd9a7030..c1b15013862 100644 --- a/gcc/data-streamer.h +++ b/gcc/data-streamer.h @@ -53,6 +53,7 @@ HOST_WIDE_INT bp_unpack_var_len_int (struct bitpack_d *); void streamer_write_zero (struct output_block *); void streamer_write_uhwi (struct output_block *, unsigned HOST_WIDE_INT); void streamer_write_hwi (struct output_block *, HOST_WIDE_INT); +void streamer_write_poly_uint64 (struct output_block *, poly_uint64); void streamer_write_gcov_count (struct output_block *, gcov_type); void streamer_write_string (struct output_block *, struct lto_output_stream *, const char *, bool); @@ -82,6 +83,7 @@ const char *bp_unpack_indexed_string (class data_in *, struct bitpack_d *, const char *bp_unpack_string (class data_in *, struct bitpack_d *); unsigned HOST_WIDE_INT streamer_read_uhwi (class lto_input_block *); HOST_WIDE_INT streamer_read_hwi (class lto_input_block *); +poly_uint64 streamer_read_poly_uint64 (class lto_input_block *); gcov_type streamer_read_gcov_count (class lto_input_block *); wide_int streamer_read_wide_int (class lto_input_block *); widest_int streamer_read_widest_int (class lto_input_block *); diff --git a/gcc/ipa-fnsummary.c b/gcc/ipa-fnsummary.c index fe125aca62c..278bf606661 100644 --- a/gcc/ipa-fnsummary.c +++ b/gcc/ipa-fnsummary.c @@ -382,7 +382,7 @@ evaluate_conditions_for_known_args (struct cgraph_node *node, continue; } - if (tree_to_shwi (TYPE_SIZE (TREE_TYPE (val))) != c->size) + if (maybe_ne (tree_to_poly_int64 (TYPE_SIZE (TREE_TYPE (val))), c->size)) { clause |= 1 << (i + predicate::first_dynamic_condition); nonspec_clause |= 1 << (i + predicate::first_dynamic_condition); @@ -922,7 +922,7 @@ mark_modified (ao_ref *ao ATTRIBUTE_UNUSED, tree vdef ATTRIBUTE_UNUSED, static tree unmodified_parm_1 (ipa_func_body_info *fbi, gimple *stmt, tree op, - HOST_WIDE_INT *size_p) + poly_int64 *size_p) { /* SSA_NAME referring to parm default def? */ if (TREE_CODE (op) == SSA_NAME @@ -930,7 +930,7 @@ unmodified_parm_1 (ipa_func_body_info *fbi, gimple *stmt, tree op, && TREE_CODE (SSA_NAME_VAR (op)) == PARM_DECL) { if (size_p) - *size_p = tree_to_shwi (TYPE_SIZE (TREE_TYPE (op))); + *size_p = tree_to_poly_int64 (TYPE_SIZE (TREE_TYPE (op))); return SSA_NAME_VAR (op); } /* Non-SSA parm reference? */ @@ -951,7 +951,7 @@ unmodified_parm_1 (ipa_func_body_info *fbi, gimple *stmt, tree op, if (!modified) { if (size_p) - *size_p = tree_to_shwi (TYPE_SIZE (TREE_TYPE (op))); + *size_p = tree_to_poly_int64 (TYPE_SIZE (TREE_TYPE (op))); return op; } } @@ -965,7 +965,7 @@ unmodified_parm_1 (ipa_func_body_info *fbi, gimple *stmt, tree op, static tree unmodified_parm (ipa_func_body_info *fbi, gimple *stmt, tree op, - HOST_WIDE_INT *size_p) + poly_int64 *size_p) { tree res = unmodified_parm_1 (fbi, stmt, op, size_p); if (res) @@ -990,7 +990,7 @@ unmodified_parm (ipa_func_body_info *fbi, gimple *stmt, tree op, static bool unmodified_parm_or_parm_agg_item (struct ipa_func_body_info *fbi, gimple *stmt, tree op, int *index_p, - HOST_WIDE_INT *size_p, + poly_int64 *size_p, struct agg_position_info *aggpos) { tree res = unmodified_parm_1 (fbi, stmt, op, size_p); @@ -1169,7 +1169,7 @@ set_cond_stmt_execution_predicate (struct ipa_func_body_info *fbi, gimple *last; tree op; int index; - HOST_WIDE_INT size; + poly_int64 size; struct agg_position_info aggpos; enum tree_code code, inverted_code; edge e; @@ -1254,7 +1254,7 @@ set_switch_stmt_execution_predicate (struct ipa_func_body_info *fbi, gimple *lastg; tree op; int index; - HOST_WIDE_INT size; + poly_int64 size; struct agg_position_info aggpos; edge e; edge_iterator ei; @@ -1393,7 +1393,7 @@ will_be_nonconstant_expr_predicate (ipa_func_body_info *fbi, { tree parm; int index; - HOST_WIDE_INT size; + poly_int64 size; while (UNARY_CLASS_P (expr)) expr = TREE_OPERAND (expr, 0); @@ -1468,7 +1468,7 @@ will_be_nonconstant_predicate (struct ipa_func_body_info *fbi, predicate op_non_const; bool is_load; int base_index; - HOST_WIDE_INT size; + poly_int64 size; struct agg_position_info aggpos; /* What statments might be optimized away @@ -1524,7 +1524,7 @@ will_be_nonconstant_predicate (struct ipa_func_body_info *fbi, op_non_const = false; FOR_EACH_SSA_TREE_OPERAND (use, stmt, iter, SSA_OP_USE) { - HOST_WIDE_INT size; + poly_int64 size; tree parm = unmodified_parm (fbi, stmt, use, &size); int index; @@ -3292,7 +3292,7 @@ inline_read_section (struct lto_file_decl_data *file_data, const char *data, { struct condition c; c.operand_num = streamer_read_uhwi (&ib); - c.size = streamer_read_uhwi (&ib); + c.size = streamer_read_poly_uint64 (&ib); c.code = (enum tree_code) streamer_read_uhwi (&ib); c.val = stream_read_tree (&ib, data_in); bp = streamer_read_bitpack (&ib); @@ -3446,7 +3446,7 @@ ipa_fn_summary_write (void) for (i = 0; vec_safe_iterate (info->conds, i, &c); i++) { streamer_write_uhwi (ob, c->operand_num); - streamer_write_uhwi (ob, c->size); + streamer_write_poly_uint64 (ob, c->size); streamer_write_uhwi (ob, c->code); stream_write_tree (ob, c->val, true); bp = bitpack_create (ob->main_stream); diff --git a/gcc/ipa-predicate.c b/gcc/ipa-predicate.c index 49622e9cd33..775f82bce9f 100644 --- a/gcc/ipa-predicate.c +++ b/gcc/ipa-predicate.c @@ -523,7 +523,7 @@ predicate::stream_out (struct output_block *ob) predicate add_condition (class ipa_fn_summary *summary, int operand_num, - HOST_WIDE_INT size, struct agg_position_info *aggpos, + poly_int64 size, struct agg_position_info *aggpos, enum tree_code code, tree val) { int i; @@ -549,7 +549,7 @@ add_condition (class ipa_fn_summary *summary, int operand_num, for (i = 0; vec_safe_iterate (summary->conds, i, &c); i++) { if (c->operand_num == operand_num - && c->size == size + && maybe_ne (c->size, size) && c->code == code && c->val == val && c->agg_contents == agg_contents diff --git a/gcc/ipa-predicate.h b/gcc/ipa-predicate.h index c2adba30551..237306dc9fe 100644 --- a/gcc/ipa-predicate.h +++ b/gcc/ipa-predicate.h @@ -31,7 +31,7 @@ struct GTY(()) condition loaded. */ HOST_WIDE_INT offset; /* Size of the access reading the data (or the PARM_DECL SSA_NAME). */ - HOST_WIDE_INT size; + poly_int64 size; tree val; int operand_num; ENUM_BITFIELD(tree_code) code : 16; @@ -228,5 +228,5 @@ private: void dump_condition (FILE *f, conditions conditions, int cond); predicate add_condition (class ipa_fn_summary *summary, int operand_num, - HOST_WIDE_INT size, struct agg_position_info *aggpos, + poly_int64 size, struct agg_position_info *aggpos, enum tree_code code, tree val); diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c index 344b78ea02f..ce669f80083 100644 --- a/gcc/ipa-prop.c +++ b/gcc/ipa-prop.c @@ -1059,7 +1059,7 @@ bool ipa_load_from_parm_agg (struct ipa_func_body_info *fbi, vec *descriptors, gimple *stmt, tree op, int *index_p, - HOST_WIDE_INT *offset_p, HOST_WIDE_INT *size_p, + HOST_WIDE_INT *offset_p, poly_int64 *size_p, bool *by_ref_p, bool *guaranteed_unmodified) { int index; @@ -4917,7 +4917,8 @@ ipcp_modif_dom_walker::before_dom_children (basic_block bb) struct ipa_agg_replacement_value *v; gimple *stmt = gsi_stmt (gsi); tree rhs, val, t; - HOST_WIDE_INT offset, size; + HOST_WIDE_INT offset; + poly_int64 size; int index; bool by_ref, vce; @@ -4952,7 +4953,8 @@ ipcp_modif_dom_walker::before_dom_children (basic_block bb) break; if (!v || v->by_ref != by_ref - || tree_to_shwi (TYPE_SIZE (TREE_TYPE (v->value))) != size) + || maybe_ne (tree_to_poly_int64 (TYPE_SIZE (TREE_TYPE (v->value))), + size)) continue; gcc_checking_assert (is_gimple_ip_invariant (v->value)); diff --git a/gcc/ipa-prop.h b/gcc/ipa-prop.h index 6470c938ecd..30948fb8854 100644 --- a/gcc/ipa-prop.h +++ b/gcc/ipa-prop.h @@ -763,7 +763,7 @@ tree ipa_find_agg_cst_for_param (struct ipa_agg_jump_function *agg, tree scalar, bool ipa_load_from_parm_agg (struct ipa_func_body_info *fbi, vec *descriptors, gimple *stmt, tree op, int *index_p, - HOST_WIDE_INT *offset_p, HOST_WIDE_INT *size_p, + HOST_WIDE_INT *offset_p, poly_int64 *size_p, bool *by_ref, bool *guaranteed_unmodified = NULL); /* Debugging interface. */