Commit 86cd0334 by Martin Jambor Committed by Martin Jambor

[PR 78140] Reuse same IPA bits and VR info

2017-03-01  Martin Jambor  <mjambor@suse.cz>

	PR lto/78140
	* ipa-prop.h (ipa_bits): Removed field known.
	(ipa_jump_func): Removed field vr_known.  Changed fields bits and m_vr
	to pointers.  Adjusted their comments to warn about their sharing.
	(ipcp_transformation_summary): Change bits to a vector of pointers.
	(ipa_check_create_edge_args): Moved to ipa-prop.c, declare.
	(ipa_get_ipa_bits_for_value): Declare.
	* tree-vrp.h (value_range): Mark as GTY((for_user)).
	* ipa-prop.c (ipa_bit_ggc_hash_traits): New.
	(ipa_bits_hash_table): Likewise.
	(ipa_vr_ggc_hash_traits): Likewise.
	(ipa_vr_hash_table): Likewise.
	(ipa_print_node_jump_functions_for_edge): Adjust for bits and m_vr
	being pointers and vr_known being removed.
	(ipa_set_jf_unknown): Likewise.
	(ipa_get_ipa_bits_for_value): New function.
	(ipa_set_jfunc_bits): Likewise.
	(ipa_get_value_range): New overloaded functions.
	(ipa_set_jfunc_vr): Likewise.
	(ipa_compute_jump_functions_for_edge): Use the above functions to
	construct bits and vr parts of jump functions.
	(ipa_check_create_edge_args): Move here from ipa-prop.h, also allocate
	ipa_bits_hash_table and ipa_vr_hash_table if they do not already
	exist.
	(ipcp_grow_transformations_if_necessary): Also allocate
	ipa_bits_hash_table and ipa_vr_hash_table if they do not already
	exist.
	(ipa_node_params_t::duplicate): Do not copy bits, just pointers to
	them.  Fix too long lines.
	(ipa_write_jump_function): Adjust for bits and m_vr being pointers and
	vr_known being removed.
	(ipa_read_jump_function): Use new setter functions to construct bits
	and vr parts of jump functions or set them to NULL.
	(write_ipcp_transformation_info): Adjust for bits being pointers.
	(read_ipcp_transformation_info): Likewise.
	(ipcp_update_bits): Likewise.  Fix excessively long lines a trailing
	space.
	Include gt-ipa-prop.h.
	* ipa-cp.c (propagate_bits_across_jump_function): Adjust for bits
	being pointers.
	(ipcp_store_bits_results): Likewise.
	(propagate_vr_across_jump_function): Adjust for m_vr being a pointer.
	Do not write to existing jump functions but use a temporary instead.

From-SVN: r245805
parent 42132674
2017-03-01 Martin Jambor <mjambor@suse.cz>
PR lto/78140
* ipa-prop.h (ipa_bits): Removed field known.
(ipa_jump_func): Removed field vr_known. Changed fields bits and m_vr
to pointers. Adjusted their comments to warn about their sharing.
(ipcp_transformation_summary): Change bits to a vector of pointers.
(ipa_check_create_edge_args): Moved to ipa-prop.c, declare.
(ipa_get_ipa_bits_for_value): Declare.
* tree-vrp.h (value_range): Mark as GTY((for_user)).
* ipa-prop.c (ipa_bit_ggc_hash_traits): New.
(ipa_bits_hash_table): Likewise.
(ipa_vr_ggc_hash_traits): Likewise.
(ipa_vr_hash_table): Likewise.
(ipa_print_node_jump_functions_for_edge): Adjust for bits and m_vr
being pointers and vr_known being removed.
(ipa_set_jf_unknown): Likewise.
(ipa_get_ipa_bits_for_value): New function.
(ipa_set_jfunc_bits): Likewise.
(ipa_get_value_range): New overloaded functions.
(ipa_set_jfunc_vr): Likewise.
(ipa_compute_jump_functions_for_edge): Use the above functions to
construct bits and vr parts of jump functions.
(ipa_check_create_edge_args): Move here from ipa-prop.h, also allocate
ipa_bits_hash_table and ipa_vr_hash_table if they do not already
exist.
(ipcp_grow_transformations_if_necessary): Also allocate
ipa_bits_hash_table and ipa_vr_hash_table if they do not already
exist.
(ipa_node_params_t::duplicate): Do not copy bits, just pointers to
them. Fix too long lines.
(ipa_write_jump_function): Adjust for bits and m_vr being pointers and
vr_known being removed.
(ipa_read_jump_function): Use new setter functions to construct bits
and vr parts of jump functions or set them to NULL.
(write_ipcp_transformation_info): Adjust for bits being pointers.
(read_ipcp_transformation_info): Likewise.
(ipcp_update_bits): Likewise. Fix excessively long lines a trailing
space.
Include gt-ipa-prop.h.
* ipa-cp.c (propagate_bits_across_jump_function): Adjust for bits
being pointers.
(ipcp_store_bits_results): Likewise.
(propagate_vr_across_jump_function): Adjust for m_vr being a pointer.
Do not write to existing jump functions but use a temporary instead.
2017-03-01 Jakub Jelinek <jakub@redhat.com>
PR c++/79681
......
......@@ -1819,8 +1819,8 @@ propagate_bits_across_jump_function (cgraph_edge *cs, int idx,
and we store it in jump function during analysis stage. */
if (src_lats->bits_lattice.bottom_p ()
&& jfunc->bits.known)
return dest_lattice->meet_with (jfunc->bits.value, jfunc->bits.mask,
&& jfunc->bits)
return dest_lattice->meet_with (jfunc->bits->value, jfunc->bits->mask,
precision);
else
return dest_lattice->meet_with (src_lats->bits_lattice, precision, sgn,
......@@ -1829,10 +1829,9 @@ propagate_bits_across_jump_function (cgraph_edge *cs, int idx,
else if (jfunc->type == IPA_JF_ANCESTOR)
return dest_lattice->set_to_bottom ();
else if (jfunc->bits.known)
return dest_lattice->meet_with (jfunc->bits.value, jfunc->bits.mask, precision);
else if (jfunc->bits)
return dest_lattice->meet_with (jfunc->bits->value, jfunc->bits->mask,
precision);
else
return dest_lattice->set_to_bottom ();
}
......@@ -1903,19 +1902,21 @@ propagate_vr_across_jump_function (cgraph_edge *cs, ipa_jump_func *jfunc,
val = fold_convert (param_type, val);
if (TREE_OVERFLOW_P (val))
val = drop_tree_overflow (val);
jfunc->vr_known = true;
jfunc->m_vr.type = VR_RANGE;
jfunc->m_vr.min = val;
jfunc->m_vr.max = val;
return dest_lat->meet_with (&jfunc->m_vr);
value_range tmpvr;
memset (&tmpvr, 0, sizeof (tmpvr));
tmpvr.type = VR_RANGE;
tmpvr.min = val;
tmpvr.max = val;
return dest_lat->meet_with (&tmpvr);
}
}
value_range vr;
if (jfunc->vr_known
&& ipa_vr_operation_and_type_effects (&vr, &jfunc->m_vr, NOP_EXPR,
if (jfunc->m_vr
&& ipa_vr_operation_and_type_effects (&vr, jfunc->m_vr, NOP_EXPR,
param_type,
TREE_TYPE (jfunc->m_vr.min)))
TREE_TYPE (jfunc->m_vr->min)))
return dest_lat->meet_with (&vr);
else
return dest_lat->set_to_bottom ();
......@@ -4870,19 +4871,17 @@ ipcp_store_bits_results (void)
for (unsigned i = 0; i < count; i++)
{
ipcp_param_lattices *plats = ipa_get_parm_lattices (info, i);
ipa_bits bits_jfunc;
ipa_bits *jfbits;
if (plats->bits_lattice.constant_p ())
{
bits_jfunc.known = true;
bits_jfunc.value = plats->bits_lattice.get_value ();
bits_jfunc.mask = plats->bits_lattice.get_mask ();
}
jfbits
= ipa_get_ipa_bits_for_value (plats->bits_lattice.get_value (),
plats->bits_lattice.get_mask ());
else
bits_jfunc.known = false;
jfbits = NULL;
ts->bits->quick_push (bits_jfunc);
if (!dump_file || !bits_jfunc.known)
ts->bits->quick_push (jfbits);
if (!dump_file || !jfbits)
continue;
if (!dumped_sth)
{
......@@ -4891,9 +4890,9 @@ ipcp_store_bits_results (void)
dumped_sth = true;
}
fprintf (dump_file, " param %i: value = ", i);
print_hex (bits_jfunc.value, dump_file);
print_hex (jfbits->value, dump_file);
fprintf (dump_file, ", mask = ");
print_hex (bits_jfunc.mask, dump_file);
print_hex (jfbits->mask, dump_file);
fprintf (dump_file, "\n");
}
}
......
......@@ -152,11 +152,10 @@ struct GTY(()) ipa_bits
Similar to ccp_lattice_t, if xth bit of mask is 0,
implies xth bit of value is constant. */
widest_int mask;
/* True if jump function is known. */
bool known;
};
/* Info about value ranges. */
struct GTY(()) ipa_vr
{
/* The data fields below are valid only if known is true. */
......@@ -175,13 +174,15 @@ struct GTY (()) ipa_jump_func
description. */
struct ipa_agg_jump_function agg;
/* Information about zero/non-zero bits. */
struct ipa_bits bits;
/* Information about zero/non-zero bits. The pointed to structure is shared
betweed different jump functions. Use ipa_set_jfunc_bits to set this
field. */
struct ipa_bits *bits;
/* Information about value range, containing valid data only when vr_known is
true. */
value_range m_vr;
bool vr_known;
true. The pointed to structure is shared betweed different jump
functions. Use ipa_set_jfunc_vr to set this field. */
struct value_range *m_vr;
enum jump_func_type type;
/* Represents a value of a jump function. pass_through is used only in jump
......@@ -547,7 +548,7 @@ struct GTY(()) ipcp_transformation_summary
/* Linked list of known aggregate values. */
ipa_agg_replacement_value *agg_values;
/* Known bits information. */
vec<ipa_bits, va_gc> *bits;
vec<ipa_bits *, va_gc> *bits;
/* Value range information. */
vec<ipa_vr, va_gc> *m_vr;
};
......@@ -630,6 +631,7 @@ extern GTY(()) vec<ipa_edge_args, va_gc> *ipa_edge_args_vector;
/* Creating and freeing ipa_node_params and ipa_edge_args. */
void ipa_create_all_node_params (void);
void ipa_create_all_edge_args (void);
void ipa_check_create_edge_args (void);
void ipa_free_edge_args_substructures (struct ipa_edge_args *);
void ipa_free_all_node_params (void);
void ipa_free_all_edge_args (void);
......@@ -651,17 +653,6 @@ ipa_check_create_node_params (void)
ipa_node_params_t (symtab, true));
}
/* This function ensures the array of edge arguments infos is big enough to
accommodate a structure for all edges and reallocates it if not. */
static inline void
ipa_check_create_edge_args (void)
{
if (vec_safe_length (ipa_edge_args_vector)
<= (unsigned) symtab->edges_max_uid)
vec_safe_grow_cleared (ipa_edge_args_vector, symtab->edges_max_uid + 1);
}
/* Returns true if the array of edge infos is large enough to accommodate an
info for EDGE. The main purpose of this function is that debug dumping
function can check info availability without causing reallocations. */
......@@ -703,6 +694,9 @@ tree ipa_get_indirect_edge_target (struct cgraph_edge *ie,
struct cgraph_edge *ipa_make_edge_direct_to_target (struct cgraph_edge *, tree,
bool speculative = false);
tree ipa_impossible_devirt_target (struct cgraph_edge *, tree);
ipa_bits *ipa_get_ipa_bits_for_value (const widest_int &value,
const widest_int &mask);
/* Functions related to both. */
void ipa_analyze_node (struct cgraph_node *);
......
......@@ -24,7 +24,7 @@ enum value_range_type { VR_UNDEFINED, VR_RANGE,
/* Range of values that can be associated with an SSA_NAME after VRP
has executed. */
struct GTY(()) value_range
struct GTY((for_user)) value_range
{
/* Lattice value represented by this range. */
enum value_range_type type;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment