From patchwork Fri Aug 26 12:34:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 783 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:ecc5:0:0:0:0:0 with SMTP id s5csp214511wro; Fri, 26 Aug 2022 05:35:01 -0700 (PDT) X-Google-Smtp-Source: AA6agR5WiZKN/HvWy0nytNggALVZXuZttLB5f4d9wDA352U9R9XUR0E9S9p+ya0xyRH41HujUfJy X-Received: by 2002:a17:907:1690:b0:731:56b6:fded with SMTP id hc16-20020a170907169000b0073156b6fdedmr5473974ejc.119.1661517301602; Fri, 26 Aug 2022 05:35:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661517301; cv=none; d=google.com; s=arc-20160816; b=TBRcGV971Sr95cV1hZsYxNSdbWSh9rm1uozCT/HSD9MIEzag5pdyc3Ne9r8/tf4a0A tg5Be7Gr1xFrONFE0AIN090sehlKr7LzuZPEc/O8ZQgyVLH9MN5UHLfHrRGPCjswmHSE oAX38lj3zkBvgcutQImIAYLS/yxxrZWB3RQOA+J9IeV5XgrAjOgsjCzJ/rO6pFem+vGy lMzla2AIl9QaQWZfYqen+PkBrE+WKBzRXXa49vL4CvcMuFySSfIxmBjBvePIZ39rFpmj hdX4Yu0Xs64gyhkOQjL6QsP0jIcqdJ/Iq7EHLEoKxNEZLZu8jOWptnZ+cy5m+29rhARH Z65A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:message-id :mime-version:subject:to:date:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=p1Ldv9ZycINS3a78pmzjnVni7zZINXqmOY2sehhSNRk=; b=bjMH04TW4JwUIQLqMNHiPmi5lUWDsjM4cfU+H1/gIVKui1LlxFTj9Ic5vmB9lTRLFR FdPzmPDqAGEsnIjib3TVYBY5g/vUUkE7X1YqwklQIeqtgQJeaIpIhQMLxwTlv5Jygkzl nTxxlEJyxf4/bnKYG4KpAIwmzfJnysDPYqQvlTItS6RyNlfLcYwrws95dRbBaDZCrtZI lmP+YaqGARqzkUJMtY45/DUqkNz/GfZZ3SvGGXRtUHX4FxHLq3IkfvNZqzwVRXQlGB2Q hp7EZwByfWEek8oj3gF+2yFoZpv4rrYyx0qrxqYVntBTmARFLdvG0bGbyK3Tfyiktq/k E6wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=VbxMQkib; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id sg42-20020a170907a42a00b0070bf25f1732si1286305ejc.155.2022.08.26.05.35.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Aug 2022 05:35:01 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=VbxMQkib; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B0231385114E for ; Fri, 26 Aug 2022 12:34:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B0231385114E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1661517294; bh=p1Ldv9ZycINS3a78pmzjnVni7zZINXqmOY2sehhSNRk=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=VbxMQkibXAhpr7cuV5Bg93lPpdT40uD4PCmZuCEULbso6AcphukDRBgwlfAycsV9k QabFVVKeQbSy1w+m9qXviT/d40+3W8Faz9/M3s0f43t/G9AWozgITRc0IdmWvvr63x 953Y6sJbEc/uD7F7yxx2jtCJmiDh4uh3n1rwgkXs= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id B418E3858C74 for ; Fri, 26 Aug 2022 12:34:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B418E3858C74 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-out2.suse.de (Postfix) with ESMTPS id 66B691F94E for ; Fri, 26 Aug 2022 12:34:09 +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 524BF13A7E for ; Fri, 26 Aug 2022 12:34:09 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 0VPxEsG9CGMXFQAAMHmgww (envelope-from ) for ; Fri, 26 Aug 2022 12:34:09 +0000 Date: Fri, 26 Aug 2022 14:34:08 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [PATCH 1/2] Improve compute_control_dep_chain documentation MIME-Version: 1.0 Message-Id: <20220826123409.524BF13A7E@imap2.suse-dmz.suse.de> X-Spam-Status: No, score=-11.8 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, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1742227166010407589?= X-GMAIL-MSGID: =?utf-8?q?1742227166010407589?= In the quest to understand how compute_control_dep_chain works I've produced the following two changes, documenting PR106754 on the way. Bootstrap and regtest is running on x86_64-unknown-linux-gnu, the changes should be no-ops but hopefully improve understanding of the code. --- The following refactors compute_control_dep_chain slightly by inlining is_loop_exit and factoring the check on the loop invariant condition. It also adds a comment as of how I understand the code and it's current problem. * gimple-predicate-analysis.cc (compute_control_dep_chain): Inline is_loop_exit and refactor, add comment about loop exits. --- gcc/gimple-predicate-analysis.cc | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/gcc/gimple-predicate-analysis.cc b/gcc/gimple-predicate-analysis.cc index 32542f93057..934e9516e7b 100644 --- a/gcc/gimple-predicate-analysis.cc +++ b/gcc/gimple-predicate-analysis.cc @@ -1110,6 +1110,10 @@ compute_control_dep_chain (basic_block dom_bb, const_basic_block dep_bb, vec &cur_cd_chain, unsigned *num_calls, unsigned in_region = 0, unsigned depth = 0) { + /* In our recursive calls this doesn't happen. */ + if (single_succ_p (dom_bb)) + return false; + if (*num_calls > (unsigned)param_uninit_control_dep_attempts) { if (dump_file) @@ -1167,7 +1171,21 @@ compute_control_dep_chain (basic_block dom_bb, const_basic_block dep_bb, basic_block cd_bb = e->dest; cur_cd_chain.safe_push (e); while (!dominated_by_p (CDI_POST_DOMINATORS, dom_bb, cd_bb) - || is_loop_exit (dom_bb, cd_bb)) + /* We want to stop when the CFG merges back from the + branch in dom_bb. The post-dominance check alone + falls foul of the case of a loop exit test branch + where the path on the loop exit post-dominates + the branch block. + The following catches this but will not allow + exploring the post-dom path further. For the + outermost recursion this means we will fail to + reach dep_bb while for others it means at least + dropping the loop exit predicate from the path + which is problematic as it increases the domain + spanned by the resulting predicate. + See gcc.dg/uninit-pred-11.c for the first case + and PR106754 for the second. */ + || single_pred_p (cd_bb)) { if (cd_bb == dep_bb) { @@ -1187,9 +1205,10 @@ compute_control_dep_chain (basic_block dom_bb, const_basic_block dep_bb, break; /* Check if DEP_BB is indirectly control-dependent on DOM_BB. */ - if (compute_control_dep_chain (cd_bb, dep_bb, cd_chains, - num_chains, cur_cd_chain, - num_calls, in_region, depth + 1)) + if (!single_succ_p (cd_bb) + && compute_control_dep_chain (cd_bb, dep_bb, cd_chains, + num_chains, cur_cd_chain, + num_calls, in_region, depth + 1)) { found_cd_chain = true; break;