Simple cost model for ipcp
Diego Novillo
dnovillo@google.com
Mon Aug 25 12:59:00 GMT 2008
On 8/24/08 5:56 AM, Jan Hubicka wrote:
> Hi
> this patch adds simple cost model into ipcp. It makes ipcp to realize
> what constant propagation is for free and what cause code size growth
> and code size growth is limited to 10%.
Nice.
> +
> + /* Estimate cost of clonning NODE. */
> + static long
Blank line after comment.
> + ipcp_estimate_clonning_cost (struct cgraph_node *node)
> + {
> + int freq_sum = 1;
> + gcov_type count_sum = 1;
> + struct cgraph_edge *e;
> + int cost;
> +
> + /* When we don't need original clone; we should always propagate. */
> + if (!ipcp_need_original_clone_p (node))
> + return 0;
> +
> + for (e = node->callers; e; e = e->next_caller)
> + if (!bitmap_bit_p (dead_nodes, e->caller->uid)
> + && !ipcp_need_redirect_p (e))
> + {
> + count_sum += e->count;
> + freq_sum += e->frequency + 1;
> + }
> +
> + cost = node->local.inline_summary.self_insns * 1000;
> + if (max_count)
> + cost /= count_sum * 1000 / max_count + 1;
> + else
> + cost /= freq_sum * 1000 / REG_BR_PROB_BASE + 1;
> + if (dump_file)
> + fprintf (dump_file, "Cost of versioning %s is %i, (size: %i, freq: %i)\n",
> + cgraph_node_name (node), cost, node->local.inline_summary.self_insns,
> + freq_sum);
> + return false;
> + }
This function returns 'long' but it seems to be returning a boolean
value. It also computes a cost, but does nothing significant with it.
> +
> + /* Return number of live constant parameters. */
> + static int
Blank line after comment. Seems to happen all over the file, so at
least it's consistent.
> "inline-unit-growth",
> "how much can given compilation unit grow because of the inlining (in percent)",
> 30, 0, 0)
> + DEFPARAM(PARAM_IPCP_UNIT_GROWTH,
> + "ipcp-unit-growth",
> + "how much can given compilation unit grow because of the interprocedural constant propagation (in percent)",
How about: "Maximum percentage that a given compilation unit may grow
due to interprocedural constant propagation."
Diego.
More information about the Gcc-patches
mailing list