From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1661517249; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=p1Ldv9ZycINS3a78pmzjnVni7zZINXqmOY2sehhSNRk=; b=OXXQw9NnkpTJnzkUE8ITVU2x0q7Va+W4yCq9hclFG+F9LMaQcXoSiX0cQ3VcL2qqeJnqcE CM4pqtO2l9zuuiUu5Hx5N35R9ChPhsiI3P6nUdbafhtr3onlCr7gxKCzFc62PmEvEjN2R7 qtGckqFQpsVLVo/hlgoFPailI0jG7Sw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1661517249; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=p1Ldv9ZycINS3a78pmzjnVni7zZINXqmOY2sehhSNRk=; b=xGnAdfdZeotZp24Ynnx/o3mLJ7yzJCjGTXf0V/IDpDQNIFPwcqgb1xlLWgXlViRQG1N6fB 4AFVvvz4ZK1lFYCA== 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) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH 1/2] Improve compute_control_dep_chain documentation MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII 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 List-Id: 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; -- 2.35.3