aboutsummaryrefslogtreecommitdiff
path: root/gcc/ipa-cp.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/ipa-cp.cc')
-rw-r--r--gcc/ipa-cp.cc193
1 files changed, 98 insertions, 95 deletions
diff --git a/gcc/ipa-cp.cc b/gcc/ipa-cp.cc
index 071c607..e056030 100644
--- a/gcc/ipa-cp.cc
+++ b/gcc/ipa-cp.cc
@@ -2749,11 +2749,22 @@ propagate_bits_across_jump_function (cgraph_edge *cs, int idx,
}
}
- if (jfunc->bits)
- return dest_lattice->meet_with (jfunc->bits->value, jfunc->bits->mask,
- precision);
- else
- return dest_lattice->set_to_bottom ();
+ Value_Range vr (parm_type);
+ if (jfunc->m_vr)
+ {
+ jfunc->m_vr->get_vrange (vr);
+ if (!vr.undefined_p () && !vr.varying_p ())
+ {
+ irange &r = as_a <irange> (vr);
+ irange_bitmask bm = r.get_bitmask ();
+ widest_int mask
+ = widest_int::from (bm.mask (), TYPE_SIGN (parm_type));
+ widest_int value
+ = widest_int::from (bm.value (), TYPE_SIGN (parm_type));
+ return dest_lattice->meet_with (value, mask, precision);
+ }
+ }
+ return dest_lattice->set_to_bottom ();
}
/* Propagate value range across jump function JFUNC that is associated with
@@ -6521,89 +6532,8 @@ ipcp_decision_stage (class ipa_topo_info *topo)
}
}
-/* Look up all the bits information that we have discovered and copy it over
- to the transformation summary. */
-
-static void
-ipcp_store_bits_results (void)
-{
- cgraph_node *node;
-
- FOR_EACH_FUNCTION_WITH_GIMPLE_BODY (node)
- {
- ipa_node_params *info = ipa_node_params_sum->get (node);
- bool dumped_sth = false;
- bool found_useful_result = false;
-
- if (!opt_for_fn (node->decl, flag_ipa_bit_cp) || !info)
- {
- if (dump_file)
- fprintf (dump_file, "Not considering %s for ipa bitwise propagation "
- "; -fipa-bit-cp: disabled.\n",
- node->dump_name ());
- continue;
- }
-
- if (info->ipcp_orig_node)
- info = ipa_node_params_sum->get (info->ipcp_orig_node);
- if (!info->lattices)
- /* Newly expanded artificial thunks do not have lattices. */
- continue;
-
- unsigned count = ipa_get_param_count (info);
- for (unsigned i = 0; i < count; i++)
- {
- ipcp_param_lattices *plats = ipa_get_parm_lattices (info, i);
- if (plats->bits_lattice.constant_p ())
- {
- found_useful_result = true;
- break;
- }
- }
-
- if (!found_useful_result)
- continue;
-
- ipcp_transformation_initialize ();
- ipcp_transformation *ts = ipcp_transformation_sum->get_create (node);
- vec_safe_reserve_exact (ts->bits, count);
-
- for (unsigned i = 0; i < count; i++)
- {
- ipcp_param_lattices *plats = ipa_get_parm_lattices (info, i);
- ipa_bits *jfbits;
-
- if (plats->bits_lattice.constant_p ())
- {
- jfbits
- = ipa_get_ipa_bits_for_value (plats->bits_lattice.get_value (),
- plats->bits_lattice.get_mask ());
- if (!dbg_cnt (ipa_cp_bits))
- jfbits = NULL;
- }
- else
- jfbits = NULL;
-
- ts->bits->quick_push (jfbits);
- if (!dump_file || !jfbits)
- continue;
- if (!dumped_sth)
- {
- fprintf (dump_file, "Propagated bits info for function %s:\n",
- node->dump_name ());
- dumped_sth = true;
- }
- fprintf (dump_file, " param %i: value = ", i);
- print_hex (jfbits->value, dump_file);
- fprintf (dump_file, ", mask = ");
- print_hex (jfbits->mask, dump_file);
- fprintf (dump_file, "\n");
- }
- }
-}
-
-/* Look up all VR information that we have discovered and copy it over
- to the transformation summary. */
+/* Look up all VR and bits information that we have discovered and copy it
+ over to the transformation summary. */
static void
ipcp_store_vr_results (void)
@@ -6613,7 +6543,10 @@ ipcp_store_vr_results (void)
FOR_EACH_FUNCTION_WITH_GIMPLE_BODY (node)
{
ipa_node_params *info = ipa_node_params_sum->get (node);
+ bool dumped_sth = false;
bool found_useful_result = false;
+ bool do_vr = true;
+ bool do_bits = true;
if (!info || !opt_for_fn (node->decl, flag_ipa_vrp))
{
@@ -6621,8 +6554,18 @@ ipcp_store_vr_results (void)
fprintf (dump_file, "Not considering %s for VR discovery "
"and propagate; -fipa-ipa-vrp: disabled.\n",
node->dump_name ());
- continue;
+ do_vr = false;
+ }
+ if (!info || !opt_for_fn (node->decl, flag_ipa_bit_cp))
+ {
+ if (dump_file)
+ fprintf (dump_file, "Not considering %s for ipa bitwise "
+ "propagation ; -fipa-bit-cp: disabled.\n",
+ node->dump_name ());
+ do_bits = false;
}
+ if (!do_bits && !do_vr)
+ continue;
if (info->ipcp_orig_node)
info = ipa_node_params_sum->get (info->ipcp_orig_node);
@@ -6634,12 +6577,18 @@ ipcp_store_vr_results (void)
for (unsigned i = 0; i < count; i++)
{
ipcp_param_lattices *plats = ipa_get_parm_lattices (info, i);
- if (!plats->m_value_range.bottom_p ()
+ if (do_vr
+ && !plats->m_value_range.bottom_p ()
&& !plats->m_value_range.top_p ())
{
found_useful_result = true;
break;
}
+ if (do_bits && plats->bits_lattice.constant_p ())
+ {
+ found_useful_result = true;
+ break;
+ }
}
if (!found_useful_result)
continue;
@@ -6651,12 +6600,53 @@ ipcp_store_vr_results (void)
for (unsigned i = 0; i < count; i++)
{
ipcp_param_lattices *plats = ipa_get_parm_lattices (info, i);
+ ipcp_bits_lattice *bits = NULL;
+
+ if (do_bits
+ && plats->bits_lattice.constant_p ()
+ && dbg_cnt (ipa_cp_bits))
+ bits = &plats->bits_lattice;
- if (!plats->m_value_range.bottom_p ()
+ if (do_vr
+ && !plats->m_value_range.bottom_p ()
&& !plats->m_value_range.top_p ()
&& dbg_cnt (ipa_cp_vr))
{
- ipa_vr vr (plats->m_value_range.m_vr);
+ if (bits)
+ {
+ Value_Range tmp = plats->m_value_range.m_vr;
+ tree type = ipa_get_type (info, i);
+ irange &r = as_a<irange> (tmp);
+ irange_bitmask bm (wide_int::from (bits->get_value (),
+ TYPE_PRECISION (type),
+ TYPE_SIGN (type)),
+ wide_int::from (bits->get_mask (),
+ TYPE_PRECISION (type),
+ TYPE_SIGN (type)));
+ r.update_bitmask (bm);
+ ipa_vr vr (tmp);
+ ts->m_vr->quick_push (vr);
+ }
+ else
+ {
+ ipa_vr vr (plats->m_value_range.m_vr);
+ ts->m_vr->quick_push (vr);
+ }
+ }
+ else if (bits)
+ {
+ tree type = ipa_get_type (info, i);
+ Value_Range tmp;
+ tmp.set_varying (type);
+ irange &r = as_a<irange> (tmp);
+ irange_bitmask bm (wide_int::from (bits->get_value (),
+ TYPE_PRECISION (type),
+ TYPE_SIGN (type)),
+ wide_int::from (bits->get_mask (),
+ TYPE_PRECISION (type),
+ TYPE_SIGN (type)));
+ r.update_bitmask (bm);
+ ipa_vr vr (tmp);
ts->m_vr->quick_push (vr);
}
else
@@ -6664,6 +6654,21 @@ ipcp_store_vr_results (void)
ipa_vr vr;
ts->m_vr->quick_push (vr);
}
+
+ if (!dump_file || !bits)
+ continue;
+
+ if (!dumped_sth)
+ {
+ fprintf (dump_file, "Propagated bits info for function %s:\n",
+ node->dump_name ());
+ dumped_sth = true;
+ }
+ fprintf (dump_file, " param %i: value = ", i);
+ print_hex (bits->get_value (), dump_file);
+ fprintf (dump_file, ", mask = ");
+ print_hex (bits->get_mask (), dump_file);
+ fprintf (dump_file, "\n");
}
}
}
@@ -6696,9 +6701,7 @@ ipcp_driver (void)
ipcp_propagate_stage (&topo);
/* Decide what constant propagation and cloning should be performed. */
ipcp_decision_stage (&topo);
- /* Store results of bits propagation. */
- ipcp_store_bits_results ();
- /* Store results of value range propagation. */
+ /* Store results of value range and bits propagation. */
ipcp_store_vr_results ();
/* Free all IPCP structures. */