From: Jakub Jelinek <jakub@redhat.com>
To: Dimitrios Apostolou <jimis@gmx.net>
Cc: gcc-patches@gcc.gnu.org, Steven Bosscher <stevenb.gcc@gmail.com>,
Alexandre Oliva <aoliva@redhat.com>
Subject: Re: [var-tracking] small speed-ups
Date: Mon, 22 Aug 2011 13:44:00 -0000 [thread overview]
Message-ID: <20110822120533.GU2687@tyan-ft48-01.lab.bos.redhat.com> (raw)
In-Reply-To: <alpine.LNX.2.02.1108221312590.1374@localhost.localdomain>
On Mon, Aug 22, 2011 at 01:30:33PM +0300, Dimitrios Apostolou wrote:
> --- gcc/var-tracking.c 2011-06-03 01:42:31 +0000
> +++ gcc/var-tracking.c 2011-08-22 09:52:08 +0000
> @@ -1069,14 +1067,14 @@ adjust_insn (basic_block bb, rtx insn)
> static inline bool
> dv_is_decl_p (decl_or_value dv)
> {
> - return !dv || (int) TREE_CODE ((tree) dv) != (int) VALUE;
> + return !dv || ((int) TREE_CODE ((tree) dv) != (int) VALUE);
> }
Why?
> /* Return true if a decl_or_value is a VALUE rtl. */
> static inline bool
> dv_is_value_p (decl_or_value dv)
> {
> - return dv && !dv_is_decl_p (dv);
> + return !dv_is_decl_p (dv);
> }
This is fine, though I don't think it makes any difference if var-tracking
is compiled with -O+ - gcc should be able to optimize the second
NULL/non-NULL check out.
> @@ -1191,7 +1189,7 @@ dv_uid2hash (dvuid uid)
> static inline hashval_t
> dv_htab_hash (decl_or_value dv)
> {
> - return dv_uid2hash (dv_uid (dv));
> + return (hashval_t) (dv_uid (dv));
> }
Why? dv_uid2hash is an inline that does exactly that.
> @@ -1202,7 +1200,7 @@ variable_htab_hash (const void *x)
> {
> const_variable const v = (const_variable) x;
>
> - return dv_htab_hash (v->dv);
> + return (hashval_t) (dv_uid (v->dv));
> }
Why?
> /* Compare the declaration of variable X with declaration Y. */
> @@ -1211,9 +1209,8 @@ static int
> variable_htab_eq (const void *x, const void *y)
> {
> const_variable const v = (const_variable) x;
> - decl_or_value dv = CONST_CAST2 (decl_or_value, const void *, y);
>
> - return (dv_as_opaque (v->dv) == dv_as_opaque (dv));
> + return (v->dv) == y;
> }
Why?
> @@ -1397,19 +1398,40 @@ shared_var_p (variable var, shared_hash
> || shared_hash_shared (vars));
> }
>
> +/* Copy all variables from hash table SRC to hash table DST without rehashing
> + any values. */
> +
> +static htab_t
> +htab_dup (htab_t src)
> +{
> + htab_t dst;
> +
> + dst = (htab_t) xmalloc (sizeof (*src));
> + memcpy (dst, src, sizeof (*src));
> + dst->entries = (void **) xmalloc (src->size * sizeof (*src->entries));
> + memcpy (dst->entries, src->entries,
> + src->size * sizeof (*src->entries));
> + return dst;
> +}
> +
This certainly doesn't belong here, it should go into libiberty/hashtab.c
and prototype into include/hashtab.h. It relies on hashtab.c
implementation details.
> @@ -2034,7 +2041,8 @@ val_resolve (dataflow_set *set, rtx val,
> static void
> dataflow_set_init (dataflow_set *set)
> {
> - init_attrs_list_set (set->regs);
> + /* Initialize the set (array) SET of attrs to empty lists. */
> + memset (set->regs, 0, sizeof (set->regs));
> set->vars = shared_hash_copy (empty_shared_hash);
> set->stack_adjust = 0;
> set->traversed_vars = NULL;
I'd say you should instead just implement init_attrs_list_set inline using
memset.
> dst->vars = (shared_hash) pool_alloc (shared_hash_pool);
> dst->vars->refcount = 1;
> dst->vars->htab
> - = htab_create (MAX (src1_elems, src2_elems), variable_htab_hash,
> + = htab_create (2 * MAX (src1_elems, src2_elems), variable_htab_hash,
> variable_htab_eq, variable_htab_free);
This looks wrong, 2 * max is definitely too much.
> @@ -8996,11 +9006,13 @@ vt_finalize (void)
>
> FOR_ALL_BB (bb)
> {
> - dataflow_set_destroy (&VTI (bb)->in);
> - dataflow_set_destroy (&VTI (bb)->out);
> + /* The "false" do_free parameter means to not bother to iterate and free
> + all hash table elements, since we'll destroy the pools. */
> + dataflow_set_destroy (&VTI (bb)->in, false);
> + dataflow_set_destroy (&VTI (bb)->out, false);
> if (VTI (bb)->permp)
> {
> - dataflow_set_destroy (VTI (bb)->permp);
> + dataflow_set_destroy (VTI (bb)->permp, false);
> XDELETE (VTI (bb)->permp);
> }
> }
>
How much does this actually speed things up (the not freeing pool allocated
stuff during finalizaqtion)? Is it really worth it?
Jakub
next prev parent reply other threads:[~2011-08-22 12:05 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-22 11:38 Dimitrios Apostolou
2011-08-22 12:21 ` [var-tracking] [not-good!] disable shared_hash and other simplifications Dimitrios Apostolou
2011-08-22 12:57 ` Jakub Jelinek
2011-08-22 18:53 ` Steven Bosscher
2011-08-22 18:55 ` Jakub Jelinek
2011-08-22 13:44 ` Jakub Jelinek [this message]
2011-08-23 12:36 ` [var-tracking] small speed-ups Dimitrios Apostolou
2011-08-23 14:51 ` Jakub Jelinek
2011-08-23 14:56 ` Dimitrios Apostolou
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110822120533.GU2687@tyan-ft48-01.lab.bos.redhat.com \
--to=jakub@redhat.com \
--cc=aoliva@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jimis@gmx.net \
--cc=stevenb.gcc@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).