public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <rguenther@suse.de>
To: Jakub Jelinek <jakub@redhat.com>,Jeff Law <law@redhat.com>,Jan
	Hubicka <jh@suse.cz>,Martin Jambor <mjambor@suse.cz>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] Fix up ipa_vr_ggc_hash_traits::hash
Date: Fri, 23 Feb 2018 18:12:00 -0000	[thread overview]
Message-ID: <E02C1D21-8092-4DB0-A543-70FF78E62260@suse.de> (raw)
In-Reply-To: <20180223170651.GE5867@tucnak>

On February 23, 2018 6:06:51 PM GMT+01:00, Jakub Jelinek <jakub@redhat.com> wrote:
>Hi!
>
>ipa_vr_ggc_hash_traits::equal does
>  return a->type == b->type && a->min == b->min && a->max == b->max;
>so it requires pointer identical type (5 value enum) and min/max,
>hopefully only INTEGER_CSTs.  Honza complained on IRC that during
>firefox a lot of time is spent in this hash table, probably because
>the hash function was poor, it hashes any ranges with the same
>min/max values but different TREE_TYPE (p->min) the same.
>
>The following patch adjusts the hash method to match the equal
>method, bootstrapped/regtested on x86_64-linux and i686-linux,
>ok for trunk?
>
>In theory we could get bigger savings by e.g. using operand_equal_p
>on p->min and p->max instead of pointer comparison, but not really sure
>if the VRP code is prepared for that.  E.g. VRP cares whether min
>or max are the minimum or maximum of the corresponding type, but if we
>ignore the type completely, it could be any other integral type.

That would certainly lead to issues.

>We'd use the same value_range memory struct for unsigned char [5, 255]
>range, where it is [5, +INF] and for int, where it is just [5, 255].
>Does LTO canonicalize INTEGER_TYPEs using type_hash_canon? 

No.  It unifies with its own logic and types are not registered with the canon hash. 

 In any
>case,
>I think further optimizations should be postponed for GCC9.

OK. 

Thanks, 
Richard. 

>2018-02-23  Jakub Jelinek  <jakub@redhat.com>
>
>	* ipa-prop.c (ipa_vr_ggc_hash_traits::hash): Hash p->min and
>	p->max as pointers rather than using iterative_hash_expr.
>
>--- gcc/ipa-prop.c.jj	2018-01-03 10:19:54.617533871 +0100
>+++ gcc/ipa-prop.c	2018-02-23 14:43:08.983733102 +0100
>@@ -111,12 +111,13 @@ struct ipa_vr_ggc_hash_traits : public g
>   typedef value_range *compare_type;
>   static hashval_t
>   hash (const value_range *p)
>-  {
>-    gcc_checking_assert (!p->equiv);
>-    hashval_t t = (hashval_t) p->type;
>-    t = iterative_hash_expr (p->min, t);
>-    return iterative_hash_expr (p->max, t);
>-  }
>+    {
>+      gcc_checking_assert (!p->equiv);
>+      inchash::hash hstate (p->type);
>+      hstate.add_ptr (p->min);
>+      hstate.add_ptr (p->max);
>+      return hstate.end ();
>+    }
>   static bool
>   equal (const value_range *a, const value_range *b)
>     {
>
>	Jakub

      reply	other threads:[~2018-02-23 18:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-23 20:49 Jakub Jelinek
2018-02-23 18:12 ` Richard Biener [this message]

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=E02C1D21-8092-4DB0-A543-70FF78E62260@suse.de \
    --to=rguenther@suse.de \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=jh@suse.cz \
    --cc=law@redhat.com \
    --cc=mjambor@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).