From patchwork Wed Nov 24 08:02:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 48049 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 802FB3858012 for ; Wed, 24 Nov 2021 08:03:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 802FB3858012 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1637741011; bh=iZ4S8lbXWBqPf+BrnPRQjdtd2nZYVXGnwoC8GXk53aM=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=XC9A5r0NFIoed6WJQ488fQvGNUvQHfMOVK2OsB0fOOWM3zjM8gmk1tis9T33lcx+A 1UYugS1/uPfccQbIAuengI+Pr5ua3Ifd2WPYqdWWx4nPS+hX1MBtl358+iZ/f90/ML 2nTo1zMYBtVqrSJg57NckVqTAhrgnF/e2Jld9UO8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 1343C385840B for ; Wed, 24 Nov 2021 08:03:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1343C385840B Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id A2C9C218EF for ; Wed, 24 Nov 2021 08:02:58 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 8F48C13A1D for ; Wed, 24 Nov 2021 08:02:58 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id fsbDIbLxnWGaHgAAMHmgww (envelope-from ) for ; Wed, 24 Nov 2021 08:02:58 +0000 Date: Wed, 24 Nov 2021 09:02:58 +0100 (CET) To: gcc-patches@gcc.gnu.org Subject: [PATCH] Avoid redundant get_loop_body calls in IVOPTs Message-ID: MIME-Version: 1.0 X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: , X-Patchwork-Original-From: Richard Biener via Gcc-patches From: Richard Biener Reply-To: Richard Biener Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" This removes redundant get_loop_body calls in IVOPTs by passing around the body we're gathering early. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. 2021-11-23 Richard Biener * tree-ssa-loop-ivopts.c (find_givs): Take loop body as argument instead of re-computing it. (find_interesting_uses): Likewise. (find_induction_variables): Pass through loop body. (tree_ssa_iv_optimize_loop): Pass down loop body. --- gcc/tree-ssa-loop-ivopts.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index 5a7fd305d91..4769b65b5d3 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -1462,22 +1462,20 @@ find_givs_in_bb (struct ivopts_data *data, basic_block bb) /* Finds general ivs. */ static void -find_givs (struct ivopts_data *data) +find_givs (struct ivopts_data *data, basic_block *body) { class loop *loop = data->current_loop; - basic_block *body = get_loop_body_in_dom_order (loop); unsigned i; for (i = 0; i < loop->num_nodes; i++) find_givs_in_bb (data, body[i]); - free (body); } /* For each ssa name defined in LOOP determines whether it is an induction variable and if so, its initial value and step. */ static bool -find_induction_variables (struct ivopts_data *data) +find_induction_variables (struct ivopts_data *data, basic_block *body) { unsigned i; bitmap_iterator bi; @@ -1485,7 +1483,7 @@ find_induction_variables (struct ivopts_data *data) if (!find_bivs (data)) return false; - find_givs (data); + find_givs (data, body); mark_bivs (data); if (dump_file && (dump_flags & TDF_DETAILS)) @@ -2736,11 +2734,10 @@ split_address_groups (struct ivopts_data *data) /* Finds uses of the induction variables that are interesting. */ static void -find_interesting_uses (struct ivopts_data *data) +find_interesting_uses (struct ivopts_data *data, basic_block *body) { basic_block bb; gimple_stmt_iterator bsi; - basic_block *body = get_loop_body (data->current_loop); unsigned i; edge e; @@ -2760,7 +2757,6 @@ find_interesting_uses (struct ivopts_data *data) if (!is_gimple_debug (gsi_stmt (bsi))) find_interesting_uses_stmt (data, gsi_stmt (bsi)); } - free (body); split_address_groups (data); @@ -8077,11 +8073,11 @@ tree_ssa_iv_optimize_loop (struct ivopts_data *data, class loop *loop, /* For each ssa name determines whether it behaves as an induction variable in some loop. */ - if (!find_induction_variables (data)) + if (!find_induction_variables (data, body)) goto finish; /* Finds interesting uses (item 1). */ - find_interesting_uses (data); + find_interesting_uses (data, body); if (data->vgroups.length () > MAX_CONSIDERED_GROUPS) goto finish;