From patchwork Thu May 6 11:53:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 1474936 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=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (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 4FbX6Q0SJfz9sVv for ; Thu, 6 May 2021 21:53:49 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AECFC3AA9410; Thu, 6 May 2021 11:53:46 +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 CEB993839C41 for ; Thu, 6 May 2021 11:53:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org CEB993839C41 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 00C5AB132 for ; Thu, 6 May 2021 11:53:43 +0000 (UTC) Date: Thu, 6 May 2021 13:53:41 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Avoid update_ssa quadraticness in loop splitting Message-ID: User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 X-Spam-Status: No, score=-11.4 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" We already take care to not apply loop splitting to IL produced by splitting so we should be able to delay updating SSA and loop-closed SSA that was left broken after loop versioning until after we processed all opportunities. Bootstrapped and tested on x86_64-unknown-linux-gnu, I've also built SPEC CPU 2017 with and without LTO for extra verification and added a -fopt-info-loop message to one path where it was missing to verify we are actually splitting loops in SPEC (we do). Pushed. 2021-05-06 Richard Biener * tree-ssa-loop-split.c (split_loop): Delay updating SSA form. Output an opt-info message. (do_split_loop_on_cond): Likewise. (tree_ssa_split_loops): Update SSA form here. --- gcc/tree-ssa-loop-split.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/gcc/tree-ssa-loop-split.c b/gcc/tree-ssa-loop-split.c index b80b6a75e62..3a09bbc39e5 100644 --- a/gcc/tree-ssa-loop-split.c +++ b/gcc/tree-ssa-loop-split.c @@ -589,7 +589,6 @@ split_loop (class loop *loop1) profile_probability::always (), true); gcc_assert (loop2); - update_ssa (TODO_update_ssa); edge new_e = connect_loops (loop1, loop2); connect_loop_phis (loop1, loop2, new_e); @@ -621,14 +620,13 @@ split_loop (class loop *loop1) free_original_copy_tables (); - /* We destroyed LCSSA form above. Eventually we might be able - to fix it on the fly, for now simply punt and use the helper. */ - rewrite_into_loop_closed_ssa_1 (NULL, 0, SSA_OP_USE, loop1); - changed = true; if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, ";; Loop split.\n"); + if (dump_enabled_p ()) + dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, guard_stmt, "loop split\n"); + /* Only deal with the first opportunity. */ break; } @@ -1532,8 +1530,6 @@ do_split_loop_on_cond (struct loop *loop1, edge invar_branch) to_loop1->flags |= true_invar ? EDGE_FALSE_VALUE : EDGE_TRUE_VALUE; to_loop2->flags |= true_invar ? EDGE_TRUE_VALUE : EDGE_FALSE_VALUE; - update_ssa (TODO_update_ssa); - /* Due to introduction of a control flow edge from loop1 latch to loop2 pre-header, we should update PHIs in loop2 to reflect this connection between loop1 and loop2. */ @@ -1541,8 +1537,6 @@ do_split_loop_on_cond (struct loop *loop1, edge invar_branch) free_original_copy_tables (); - rewrite_into_loop_closed_ssa_1 (NULL, 0, SSA_OP_USE, loop1); - return true; } @@ -1644,7 +1638,10 @@ tree_ssa_split_loops (void) free_dominance_info (CDI_POST_DOMINATORS); if (changed) - return TODO_cleanup_cfg; + { + rewrite_into_loop_closed_ssa (NULL, TODO_update_ssa); + return TODO_cleanup_cfg; + } return 0; }