public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Martin Jambor <mjambor@suse.cz>
To: Aldy Hernandez via Gcc-patches <gcc-patches@gcc.gnu.org>,
	GCC patches <gcc-patches@gcc.gnu.org>
Cc: Andrew MacLeod <amacleod@redhat.com>,
	Aldy Hernandez <aldyh@redhat.com>, Jan Hubicka <hubicka@ucw.cz>
Subject: Re: [PATCH] Implement ipa_vr hashing.
Date: Mon, 26 Jun 2023 18:40:33 +0200	[thread overview]
Message-ID: <ri67crqqiri.fsf@suse.cz> (raw)
In-Reply-To: <20230522185622.537454-2-aldyh@redhat.com>

Hi,

On Mon, May 22 2023, Aldy Hernandez via Gcc-patches wrote:
> Implement hashing for ipa_vr.  When all is said and done, all these
> patches incurr a 7.64% slowdown for ipa-cp, with is entirely covered by
> the similar 7% increase in this area last week.  So we get type agnostic
> ranges with "infinite" range precision close to free.
>
> There is no change in overall compilation.
>
> OK?
>

One small request....

> gcc/ChangeLog:
>
> 	* ipa-prop.cc (struct ipa_vr_ggc_hash_traits): Adjust for use with
> 	ipa_vr instead of value_range.
> 	(gt_pch_nx): Same.
> 	(gt_ggc_mx): Same.
> 	(ipa_get_value_range): Same.
> 	* value-range.cc (gt_pch_nx): Move to ipa-prop.cc and adjust for
> 	ipa_vr.
> 	(gt_ggc_mx): Same.
> ---
>  gcc/ipa-prop.cc    | 76 +++++++++++++++++++++++++++-------------------
>  gcc/value-range.cc | 15 ---------
>  2 files changed, 45 insertions(+), 46 deletions(-)
>
> diff --git a/gcc/ipa-prop.cc b/gcc/ipa-prop.cc
> index c46a89f1b49..6383bc11e0a 100644
> --- a/gcc/ipa-prop.cc
> +++ b/gcc/ipa-prop.cc
> @@ -109,53 +109,53 @@ struct ipa_bit_ggc_hash_traits : public ggc_cache_remove <ipa_bits *>
>  /* Hash table for avoid repeated allocations of equal ipa_bits.  */
>  static GTY ((cache)) hash_table<ipa_bit_ggc_hash_traits> *ipa_bits_hash_table;
>  
> -/* Traits for a hash table for reusing value_ranges used for IPA.  Note that
> -   the equiv bitmap is not hashed and is expected to be NULL.  */
> +/* Traits for a hash table for reusing ranges.  */
>  
> -struct ipa_vr_ggc_hash_traits : public ggc_cache_remove <value_range *>
> +struct ipa_vr_ggc_hash_traits : public ggc_cache_remove <ipa_vr *>
>  {
> -  typedef value_range *value_type;
> -  typedef value_range *compare_type;
> +  typedef ipa_vr *value_type;
> +  typedef const vrange *compare_type;
>    static hashval_t
> -  hash (const value_range *p)
> +  hash (const ipa_vr *p)
>      {
> -      tree min, max;
> -      value_range_kind kind = get_legacy_range (*p, min, max);
> -      inchash::hash hstate (kind);
> -      inchash::add_expr (min, hstate);
> -      inchash::add_expr (max, hstate);
> +      // This never get called, except in the verification code, as
> +      // ipa_get_value_range() calculates the hash itself.  This
> +      // function is mostly here for completness' sake.
> +      Value_Range vr;
> +      p->get_vrange (vr);
> +      inchash::hash hstate;
> +      add_vrange (vr, hstate);
>        return hstate.end ();
>      }
>    static bool
> -  equal (const value_range *a, const value_range *b)
> +  equal (const ipa_vr *a, const vrange *b)
>      {
> -      return (types_compatible_p (a->type (), b->type ())
> -	      && *a == *b);
> +      return a->equal_p (*b);
>      }
>    static const bool empty_zero_p = true;
>    static void
> -  mark_empty (value_range *&p)
> +  mark_empty (ipa_vr *&p)
>      {
>        p = NULL;
>      }
>    static bool
> -  is_empty (const value_range *p)
> +  is_empty (const ipa_vr *p)
>      {
>        return p == NULL;
>      }
>    static bool
> -  is_deleted (const value_range *p)
> +  is_deleted (const ipa_vr *p)
>      {
> -      return p == reinterpret_cast<const value_range *> (1);
> +      return p == reinterpret_cast<const ipa_vr *> (1);
>      }
>    static void
> -  mark_deleted (value_range *&p)
> +  mark_deleted (ipa_vr *&p)
>      {
> -      p = reinterpret_cast<value_range *> (1);
> +      p = reinterpret_cast<ipa_vr *> (1);
>      }
>  };
>  
> -/* Hash table for avoid repeated allocations of equal value_ranges.  */
> +/* Hash table for avoid repeated allocations of equal ranges.  */
>  static GTY ((cache)) hash_table<ipa_vr_ggc_hash_traits> *ipa_vr_hash_table;
>  
>  /* Holders of ipa cgraph hooks: */
> @@ -265,6 +265,22 @@ ipa_vr::dump (FILE *out) const
>      fprintf (out, "NO RANGE");
>  }
>  
> +// ?? These stubs are because we use an ipa_vr in a hash_traits and
> +// hash-traits.h defines an extern of gt_ggc_mx (T &) instead of
> +// picking up the gt_ggc_mx (T *) version.

If you mean FIXME or TODO, please replace the "??" string with one of
those.  Otherwise please just remove it or specify what you mean in some
clearer way.

OK with that change.

Thanks,

Martin



> +void
> +gt_pch_nx (ipa_vr *&x)
> +{
> +  return gt_pch_nx ((ipa_vr *) x);
> +}
> +
> +void
> +gt_ggc_mx (ipa_vr *&x)
> +{
> +  return gt_ggc_mx ((ipa_vr *) x);
> +}
> +
> +

[...]

  parent reply	other threads:[~2023-06-26 16:40 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-22 18:56 [PATCH] Convert ipa_jump_func to use ipa_vr instead of a value_range Aldy Hernandez
2023-05-22 18:56 ` [PATCH] Implement ipa_vr hashing Aldy Hernandez
2023-05-29 14:51   ` Martin Jambor
2023-06-07 10:01     ` Aldy Hernandez
2023-06-10 20:30     ` Aldy Hernandez
2023-06-14 12:11       ` Aldy Hernandez
2023-06-22  5:49         ` Aldy Hernandez
2023-06-26  9:22           ` Aldy Hernandez
2023-06-26  9:23             ` Aldy Hernandez
2023-06-26 16:40   ` Martin Jambor [this message]
2023-05-22 18:56 ` [PATCH] Convert remaining uses of value_range in ipa-*.cc to Value_Range Aldy Hernandez
2023-06-14 12:10   ` Aldy Hernandez
2023-06-22  5:49     ` Aldy Hernandez
2023-06-26 16:41   ` Martin Jambor
2023-06-14 12:09 ` [PATCH] Convert ipa_jump_func to use ipa_vr instead of a value_range Aldy Hernandez
2023-06-22  5:49   ` Aldy Hernandez
2023-06-26 16:40 ` Martin Jambor

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=ri67crqqiri.fsf@suse.cz \
    --to=mjambor@suse.cz \
    --cc=aldyh@redhat.com \
    --cc=amacleod@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hubicka@ucw.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).