From patchwork Tue Feb 16 12:14:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 1440901 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Dg0Jc3KJXz9sRN for ; Tue, 16 Feb 2021 23:14:24 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 464263972421; Tue, 16 Feb 2021 12:14:22 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id 2A06D3894401 for ; Tue, 16 Feb 2021 12:14:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2A06D3894401 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rguenther@suse.de X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 19B2BAF2C for ; Tue, 16 Feb 2021 12:14:18 +0000 (UTC) Date: Tue, 16 Feb 2021 13:14:17 +0100 (CET) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/38474 - improve PTA varinfo sorting Message-ID: User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" This improves a previous heuristic to sort address-taken variables first (because those appear in points-to bitmaps) by tracking which variables appear in ADDRESSOF constraints (there's also graph->address_taken but that's computed only later). This shaves off 30s worth of compile-time for the full testcase in PR38474 (which then still takes 965s to compile at -O2). Bootstrapped on x86_64-unknown-linux-gnu, testing in progress. 2021-02-16 Richard Biener PR tree-optimization/38474 * tree-ssa-structalias.c (variable_info::address_taken): New. (new_var_info): Initialize address_taken. (process_constraint): Set address_taken. (solve_constraints): Use the new address_taken flag rather than is_reg_var for sorting variables. (dump_constraint): Dump the variable number if the name is just NULL. --- gcc/tree-ssa-structalias.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c index d6b2661fa5e..529ec3a5b80 100644 --- a/gcc/tree-ssa-structalias.c +++ b/gcc/tree-ssa-structalias.c @@ -280,6 +280,9 @@ struct variable_info /* True if this represents a IPA function info. */ unsigned int is_fn_info : 1; + /* True if this appears as RHS in a ADDRESSOF constraint. */ + unsigned int address_taken : 1; + /* ??? Store somewhere better. */ unsigned short ruid; @@ -393,6 +396,7 @@ new_var_info (tree t, const char *name, bool add_id) ret->is_global_var = (t == NULL_TREE); ret->is_ipa_escape_point = false; ret->is_fn_info = false; + ret->address_taken = false; if (t && DECL_P (t)) ret->is_global_var = (is_global_var (t) /* We have to treat even local register variables @@ -674,7 +678,10 @@ dump_constraint (FILE *file, constraint_t c) fprintf (file, "&"); else if (c->lhs.type == DEREF) fprintf (file, "*"); - fprintf (file, "%s", get_varinfo (c->lhs.var)->name); + if (dump_file) + fprintf (file, "%s", get_varinfo (c->lhs.var)->name); + else + fprintf (file, "V%d", c->lhs.var); if (c->lhs.offset == UNKNOWN_OFFSET) fprintf (file, " + UNKNOWN"); else if (c->lhs.offset != 0) @@ -684,7 +691,10 @@ dump_constraint (FILE *file, constraint_t c) fprintf (file, "&"); else if (c->rhs.type == DEREF) fprintf (file, "*"); - fprintf (file, "%s", get_varinfo (c->rhs.var)->name); + if (dump_file) + fprintf (file, "%s", get_varinfo (c->rhs.var)->name); + else + fprintf (file, "V%d", c->rhs.var); if (c->rhs.offset == UNKNOWN_OFFSET) fprintf (file, " + UNKNOWN"); else if (c->rhs.offset != 0) @@ -3101,6 +3111,8 @@ process_constraint (constraint_t t) else { gcc_assert (rhs.type != ADDRESSOF || rhs.offset == 0); + if (rhs.type == ADDRESSOF) + get_varinfo (get_varinfo (rhs.var)->head)->address_taken = true; constraints.safe_push (t); } } @@ -7288,15 +7300,14 @@ solve_constraints (void) unsigned int *map = XNEWVEC (unsigned int, varmap.length ()); for (unsigned i = 0; i < integer_id + 1; ++i) map[i] = i; - /* Start with non-register vars (as possibly address-taken), followed - by register vars as conservative set of vars never appearing in - the points-to solution bitmaps. */ + /* Start with address-taken vars, followed by not address-taken vars + to move vars never appearing in the points-to solution bitmaps last. */ unsigned j = integer_id + 1; for (unsigned i = integer_id + 1; i < varmap.length (); ++i) - if (! varmap[i]->is_reg_var) + if (varmap[varmap[i]->head]->address_taken) map[i] = j++; for (unsigned i = integer_id + 1; i < varmap.length (); ++i) - if (varmap[i]->is_reg_var) + if (! varmap[varmap[i]->head]->address_taken) map[i] = j++; /* Shuffle varmap according to map. */ for (unsigned i = integer_id + 1; i < varmap.length (); ++i)