public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: "Martin Liška" <mliska@suse.cz>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>,
	Alexander Monakov <amonakov@ispras.ru>
Subject: Re: [PATCH] Speed up qsort in IPA ICF
Date: Thu, 19 Sep 2019 13:09:00 -0000	[thread overview]
Message-ID: <CAFiYyc36y7x5e1_d1oxMshtJi+gy_de0+fb-=Upj7a050ipi_g@mail.gmail.com> (raw)
In-Reply-To: <e51cbe6c-b917-446c-c190-01a3d03b363f@suse.cz>

On Thu, Sep 19, 2019 at 3:02 PM Martin Liška <mliska@suse.cz> wrote:
>
> On 9/19/19 1:01 PM, Richard Biener wrote:
> > On Thu, Sep 19, 2019 at 11:06 AM Martin Liška <mliska@suse.cz> wrote:
> >>
> >> Hi.
> >>
> >> As Alexander pointed out, the sort_congruence_class_groups_by_decl_uid is the most
> >> expensive qsort operator in tramp3d compilation. It does unfortunate 7 pointer dereferences
> >> via: DECL_UID (classes[i]->classes[0]->members[0]->decl). I'm suggesting to cache that
> >> in congruence_class_group.
> >>
> >> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
> >>
> >> Ready to be installed?
> >
> > Since we're populating the classes vector right before you could elide
> > the new field and do it in the same iteration by having
> >
> > auto_vec <std::pair<congruence_class_group *, unsigned> > classes
> >
> > and pushing *it, DECL_UID and then sorting by the readily available
> > UID in the data?  That makes the sort use a linear memory region
> > w/o dereferences.
>
> Good point, there's a tested patch.

OK.

Thanks,
Richard.

> Martin
>
> >
> > Richard.
> >
> >> Thanks,
> >> Martin
> >>
> >> gcc/ChangeLog:
> >>
> >> 2019-09-19  Martin Liska  <mliska@suse.cz>
> >>
> >>         * ipa-icf.c (sort_sem_items_by_decl_uid): Simplify comparator.
> >>         (sort_congruence_classes_by_decl_uid): Likewise.
> >>         (sort_congruence_class_groups_by_decl_uid): Use
> >>         congruence_class_group::uid.
> >>         (sem_item_optimizer::merge_classes): Cache
> >>         DECL_UID (classes[i]->classes[0]->members[0]->decl).
> >>         * ipa-icf.h (struct congruence_class_group): New field.
> >> ---
> >>  gcc/ipa-icf.c | 29 +++++------------------------
> >>  gcc/ipa-icf.h |  1 +
> >>  2 files changed, 6 insertions(+), 24 deletions(-)
> >>
> >>
>

  reply	other threads:[~2019-09-19 13:09 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-19  9:06 Martin Liška
2019-09-19 11:01 ` Richard Biener
2019-09-19 13:02   ` Martin Liška
2019-09-19 13:09     ` Richard Biener [this message]
2019-09-19 13:15       ` Alexander Monakov
2019-09-19 13:18         ` Richard Biener
2019-09-19 13:32           ` Martin Liška

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='CAFiYyc36y7x5e1_d1oxMshtJi+gy_de0+fb-=Upj7a050ipi_g@mail.gmail.com' \
    --to=richard.guenther@gmail.com \
    --cc=amonakov@ispras.ru \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=mliska@suse.cz \
    /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).