From patchwork Mon Jan 9 15:04:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 90474 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp650378obz; Mon, 9 Jan 2017 07:04:44 -0800 (PST) X-Received: by 10.84.128.67 with SMTP id 61mr122080400pla.153.1483974284809; Mon, 09 Jan 2017 07:04:44 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id 15si5430956pfz.175.2017.01.09.07.04.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Jan 2017 07:04:44 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-445689-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-445689-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-445689-patch=linaro.org@gcc.gnu.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=LUof0pcF6ocdpM1BZ UDHyC6W48DXrpqsoeAQdTpGfmWZHmhjHs1I5lU4tof9LgjVnml9qm9ScE5fEAULP PwzSE1/n/T2H9CLkM+VUaU2ob+JvitQCrOT+KH7PEd8GBdrF5wCxD0u4p1Zqf3j4 dcc9/flrHllTT7b1BUJ/JbBiOM= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=8pQT/pJgKEkZL2rDocbpSBF kZ3o=; b=l/AYwR6Hgvk4+2oNrQDZE5S7ZwIGVfsGP7upVAbrNTH6EbUdHbct0pY ufSHimQ443Lx64anvhnKvHWTPOE7MphBj2dioPP4ac1eOF1Ghl6oPBNKmALUYrFo m4+hlkG/XraqQTJhUyng+q1WfxVbn0nAPwpHBdn4fgxpal18XDh8= Received: (qmail 18950 invoked by alias); 9 Jan 2017 15:04:24 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 18887 invoked by uid 89); 9 Jan 2017 15:04:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 09 Jan 2017 15:04:12 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 27ED2ACA1; Mon, 9 Jan 2017 15:04:10 +0000 (UTC) Subject: [PATCH 1/2] Revert m_classes_vec introduction. To: Richard Biener , Alexandre Oliva , Jakub Jelinek References: <20170105085729.GU21933@tucnak> <20170105220218.GF21933@tucnak> <0b1a1a91-260b-8684-8264-1fab3152246f@suse.cz> Cc: GCC Patches From: =?UTF-8?Q?Martin_Li=c5=a1ka?= Message-ID: <1bf4df91-5398-2c09-ab47-503d30bfc485@suse.cz> Date: Mon, 9 Jan 2017 16:04:08 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <0b1a1a91-260b-8684-8264-1fab3152246f@suse.cz> X-IsSubscribed: yes First patch removes basically what was installed by Jakub in r242910, except formatting changes. Martin >From 32f4ccb48dfd84e4f64fb38f5122f5dc61482f3b Mon Sep 17 00:00:00 2001 From: marxin Date: Fri, 6 Jan 2017 11:36:13 +0100 Subject: [PATCH 1/2] Revert m_classes_vec introduction. gcc/ChangeLog: 2017-01-06 Martin Liska * ipa-icf.c (sem_item_optimizer::sem_item_optimizer): Remove usage of m_classes_vec. (sem_item_optimizer::~sem_item_optimizer): Likewise. (sem_item_optimizer::get_group_by_hash): Likewise. (sem_item_optimizer::subdivide_classes_by_equality): Likewise. (sem_item_optimizer::subdivide_classes_by_sensitive_refs): Likewise. (sem_item_optimizer::verify_classes): Likewise. (sem_item_optimizer::process_cong_reduction): Likewise. (sem_item_optimizer::dump_cong_classes): Likewise. (sem_item_optimizer::merge_classes): Likewise. * ipa-icf.h (congruence_class_hash): Rename from congruence_class_group_hash. Remove declaration of m_classes_vec. --- gcc/ipa-icf.c | 106 +++++++++++++++++++++++++++------------------------------- gcc/ipa-icf.h | 7 ++-- 2 files changed, 51 insertions(+), 62 deletions(-) diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c index d3f2ca14eac..28de251c421 100644 --- a/gcc/ipa-icf.c +++ b/gcc/ipa-icf.c @@ -2288,7 +2288,6 @@ sem_item_optimizer::sem_item_optimizer () m_varpool_node_hooks (NULL) { m_items.create (0); - m_classes_vec.create (0); bitmap_obstack_initialize (&m_bmstack); } @@ -2297,19 +2296,18 @@ sem_item_optimizer::~sem_item_optimizer () for (unsigned int i = 0; i < m_items.length (); i++) delete m_items[i]; - unsigned int l; - congruence_class_group *it; - FOR_EACH_VEC_ELT (m_classes_vec, l, it) + + for (hash_table::iterator it = m_classes.begin (); + it != m_classes.end (); ++it) { - for (unsigned int i = 0; i < it->classes.length (); i++) - delete it->classes[i]; + for (unsigned int i = 0; i < (*it)->classes.length (); i++) + delete (*it)->classes[i]; - it->classes.release (); - free (it); + (*it)->classes.release (); + free (*it); } m_items.release (); - m_classes_vec.release (); bitmap_obstack_release (&m_bmstack); } @@ -2502,7 +2500,6 @@ sem_item_optimizer::get_group_by_hash (hashval_t hash, sem_item_type type) else { item->classes.create (1); - m_classes_vec.safe_push (item); *slot = item; } @@ -2847,15 +2844,14 @@ sem_item_optimizer::parse_nonsingleton_classes (void) void sem_item_optimizer::subdivide_classes_by_equality (bool in_wpa) { - unsigned int l; - congruence_class_group *it; - FOR_EACH_VEC_ELT (m_classes_vec, l, it) + for (hash_table ::iterator it = m_classes.begin (); + it != m_classes.end (); ++it) { - unsigned int class_count = it->classes.length (); + unsigned int class_count = (*it)->classes.length (); for (unsigned i = 0; i < class_count; i++) { - congruence_class *c = it->classes[i]; + congruence_class *c = (*it)->classes[i]; if (c->members.length() > 1) { @@ -2864,7 +2860,7 @@ sem_item_optimizer::subdivide_classes_by_equality (bool in_wpa) sem_item *first = c->members[0]; new_vector.safe_push (first); - unsigned class_split_first = it->classes.length (); + unsigned class_split_first = (*it)->classes.length (); for (unsigned j = 1; j < c->members.length (); j++) { @@ -2881,9 +2877,9 @@ sem_item_optimizer::subdivide_classes_by_equality (bool in_wpa) bool integrated = false; for (unsigned k = class_split_first; - k < it->classes.length (); k++) + k < (*it)->classes.length (); k++) { - sem_item *x = it->classes[k]->members[0]; + sem_item *x = (*it)->classes[k]->members[0]; bool equals = in_wpa ? x->equals_wpa (item, m_symtab_node_map) : x->equals (item, m_symtab_node_map); @@ -2891,7 +2887,7 @@ sem_item_optimizer::subdivide_classes_by_equality (bool in_wpa) if (equals) { integrated = true; - add_item_to_class (it->classes[k], item); + add_item_to_class ((*it)->classes[k], item); break; } @@ -2904,7 +2900,7 @@ sem_item_optimizer::subdivide_classes_by_equality (bool in_wpa) m_classes_count++; add_item_to_class (c, item); - it->classes.safe_push (c); + (*it)->classes.safe_push (c); } } } @@ -2935,16 +2931,15 @@ sem_item_optimizer::subdivide_classes_by_sensitive_refs () unsigned newly_created_classes = 0; - unsigned int l; - congruence_class_group *it; - FOR_EACH_VEC_ELT (m_classes_vec, l, it) + for (hash_table ::iterator it = m_classes.begin (); + it != m_classes.end (); ++it) { - unsigned int class_count = it->classes.length (); + unsigned int class_count = (*it)->classes.length (); auto_vec new_classes; for (unsigned i = 0; i < class_count; i++) { - congruence_class *c = it->classes[i]; + congruence_class *c = (*it)->classes[i]; if (c->members.length() > 1) { @@ -2988,7 +2983,7 @@ sem_item_optimizer::subdivide_classes_by_sensitive_refs () if (first_class) { - it->classes[i] = new_cls; + (*it)->classes[i] = new_cls; first_class = false; } else @@ -3010,7 +3005,7 @@ sem_item_optimizer::subdivide_classes_by_sensitive_refs () } for (unsigned i = 0; i < new_classes.length (); i++) - it->classes.safe_push (new_classes[i]); + (*it)->classes.safe_push (new_classes[i]); } return newly_created_classes; @@ -3030,13 +3025,12 @@ sem_item_optimizer::checking_verify_classes (void) void sem_item_optimizer::verify_classes (void) { - unsigned int l; - congruence_class_group *it; - FOR_EACH_VEC_ELT (m_classes_vec, l, it) + for (hash_table::iterator it = m_classes.begin (); + it != m_classes.end (); ++it) { - for (unsigned int i = 0; i < it->classes.length (); i++) + for (unsigned int i = 0; i < (*it)->classes.length (); i++) { - congruence_class *cls = it->classes[i]; + congruence_class *cls = (*it)->classes[i]; gcc_assert (cls); gcc_assert (cls->members.length () > 0); @@ -3302,12 +3296,11 @@ sem_item_optimizer::worklist_pop (void) void sem_item_optimizer::process_cong_reduction (void) { - unsigned int l; - congruence_class_group *it; - FOR_EACH_VEC_ELT (m_classes_vec, l, it) - for (unsigned i = 0; i < it->classes.length (); i++) - if (it->classes[i]->is_class_used ()) - worklist_push (it->classes[i]); + for (hash_table::iterator it = m_classes.begin (); + it != m_classes.end (); ++it) + for (unsigned i = 0; i < (*it)->classes.length (); i++) + if ((*it)->classes[i]->is_class_used ()) + worklist_push ((*it)->classes[i]); if (dump_file) fprintf (dump_file, "Worklist has been filled with: %lu\n", @@ -3347,12 +3340,11 @@ sem_item_optimizer::dump_cong_classes (void) unsigned int max_index = 0; unsigned int* histogram = XCNEWVEC (unsigned int, m_items.length () + 1); - unsigned int l; - congruence_class_group *it; - FOR_EACH_VEC_ELT (m_classes_vec, l, it) - for (unsigned i = 0; i < it->classes.length (); i++) + for (hash_table::iterator it = m_classes.begin (); + it != m_classes.end (); ++it) + for (unsigned i = 0; i < (*it)->classes.length (); i++) { - unsigned int c = it->classes[i]->members.length (); + unsigned int c = (*it)->classes[i]->members.length (); histogram[c]++; if (c > max_index) @@ -3369,18 +3361,18 @@ sem_item_optimizer::dump_cong_classes (void) fprintf (dump_file, "\n\n"); - if (dump_flags & TDF_DETAILS) - FOR_EACH_VEC_ELT (m_classes_vec, l, it) + for (hash_table::iterator it = m_classes.begin (); + it != m_classes.end (); ++it) { fprintf (dump_file, " group: with %u classes:\n", - it->classes.length ()); + (*it)->classes.length ()); - for (unsigned i = 0; i < it->classes.length (); i++) + for (unsigned i = 0; i < (*it)->classes.length (); i++) { - it->classes[i]->dump (dump_file, 4); + (*it)->classes[i]->dump (dump_file, 4); - if (i < it->classes.length () - 1) + if (i < (*it)->classes.length () - 1) fprintf (dump_file, " "); } } @@ -3405,12 +3397,11 @@ sem_item_optimizer::merge_classes (unsigned int prev_class_count) bool merged_p = false; - unsigned int l; - congruence_class_group *it; - FOR_EACH_VEC_ELT (m_classes_vec, l, it) - for (unsigned int i = 0; i < it->classes.length (); i++) + for (hash_table::iterator it = m_classes.begin (); + it != m_classes.end (); ++it) + for (unsigned int i = 0; i < (*it)->classes.length (); i++) { - congruence_class *c = it->classes[i]; + congruence_class *c = (*it)->classes[i]; if (c->members.length () > 1) { non_singular_classes_count++; @@ -3435,10 +3426,11 @@ sem_item_optimizer::merge_classes (unsigned int prev_class_count) item_count ? 100.0f * equal_items / item_count : 0.0f); } - FOR_EACH_VEC_ELT (m_classes_vec, l, it) - for (unsigned int i = 0; i < it->classes.length (); i++) + for (hash_table::iterator it = m_classes.begin (); + it != m_classes.end (); ++it) + for (unsigned int i = 0; i < (*it)->classes.length (); i++) { - congruence_class *c = it->classes[i]; + congruence_class *c = (*it)->classes[i]; if (c->members.length () == 1) continue; diff --git a/gcc/ipa-icf.h b/gcc/ipa-icf.h index 05fe2a83dad..c57224c1517 100644 --- a/gcc/ipa-icf.h +++ b/gcc/ipa-icf.h @@ -442,7 +442,7 @@ struct congruence_class_group }; /* Congruence class set structure. */ -struct congruence_class_group_hash : nofree_ptr_hash +struct congruence_class_hash : nofree_ptr_hash { static inline hashval_t hash (const congruence_class_group *item) { @@ -610,10 +610,7 @@ private: hash_set m_removed_items_set; /* Hashtable of congruence classes. */ - hash_table m_classes; - - /* Vector of congruence classes. */ - vec m_classes_vec; + hash_table m_classes; /* Count of congruence classes. */ unsigned int m_classes_count; -- 2.11.0