From: Jan Hubicka <hubicka@ucw.cz>
To: gcc-patches@gcc.gnu.org, rguenther@suse.de
Subject: Compute canonical type by main variants
Date: Sat, 30 May 2015 21:18:00 -0000 [thread overview]
Message-ID: <20150530200421.GB83976@kam.mff.cuni.cz> (raw)
Richard,
this patch makes canonical_type to be computed via the hash only for main
variants of types. The idea is to save some lookups because most types are
variants and should match.
I also added sanity checking about that.
Bootstrapped/regtested ppc-linux, OK?
Honza
* lto.c (iterative_hash_canonical_type,
gimple_register_canonical_type): only hash main variants of types
* tree.c (verify_type_variant): Verify that type and variant is
compatible.
(gimple_canonical_types_compatible_p): Look for main variants.
Index: lto/lto.c
===================================================================
--- lto/lto.c (revision 223883)
+++ lto/lto.c (working copy)
@@ -413,6 +413,9 @@ static void
iterative_hash_canonical_type (tree type, inchash::hash &hstate)
{
hashval_t v;
+
+ /* All type variants have same TYPE_CANONICAL. */
+ type = TYPE_MAIN_VARIANT (type);
/* An already processed type. */
if (TYPE_CANONICAL (type))
{
@@ -498,7 +501,15 @@ gimple_register_canonical_type (tree t)
if (TYPE_CANONICAL (t) || !type_with_alias_set_p (t))
return;
- gimple_register_canonical_type_1 (t, hash_canonical_type (t));
+ /* Canonical types are same among all complete variants. */
+ if (TYPE_CANONICAL (TYPE_MAIN_VARIANT (t)))
+ TYPE_CANONICAL (t) = TYPE_CANONICAL (TYPE_MAIN_VARIANT (t));
+ else
+ {
+ gimple_register_canonical_type_1 (TYPE_MAIN_VARIANT (t),
+ hash_canonical_type (TYPE_MAIN_VARIANT (t)));
+ TYPE_CANONICAL (t) = TYPE_CANONICAL (TYPE_MAIN_VARIANT (t));
+ }
}
/* Re-compute TYPE_CANONICAL for NODE and related types. */
Index: tree.c
===================================================================
--- tree.c (revision 223883)
+++ tree.c (working copy)
@@ -12819,6 +12819,17 @@ verify_type_variant (const_tree t, tree
debug_tree (TREE_TYPE (t));
return false;
}
+ if (type_with_alias_set_p (t)
+ && !gimple_canonical_types_compatible_p (t, tv, false))
+ {
+ error ("type is not compatible with its vairant");
+ debug_tree (tv);
+ error ("type variant's TREE_TYPE");
+ debug_tree (TREE_TYPE (tv));
+ error ("type's TREE_TYPE");
+ debug_tree (TREE_TYPE (t));
+ return false;
+ }
return true;
#undef verify_variant_match
}
@@ -12843,7 +12854,13 @@ bool
gimple_canonical_types_compatible_p (const_tree t1, const_tree t2,
bool trust_type_canonical)
{
- /* Before starting to set up the SCC machinery handle simple cases. */
+ /* Type variants should be same as the main variant. When not doing sanity
+ checking to verify this fact, go to main variants and save some work. */
+ if (trust_type_canonical)
+ {
+ t1 = TYPE_MAIN_VARIANT (t1);
+ t2 = TYPE_MAIN_VARIANT (t2);
+ }
/* Check first for the obvious case of pointer identity. */
if (t1 == t2)
next reply other threads:[~2015-05-30 20:04 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-30 21:18 Jan Hubicka [this message]
2015-06-03 11:41 ` Richard Biener
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=20150530200421.GB83976@kam.mff.cuni.cz \
--to=hubicka@ucw.cz \
--cc=gcc-patches@gcc.gnu.org \
--cc=rguenther@suse.de \
/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).