From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id 5CE543854157 for ; Fri, 26 Aug 2022 12:34:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5CE543854157 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 4EA331F94E for ; Fri, 26 Aug 2022 12:34:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1661517254; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=RXEn1yVK7Xl+j0Wqvkg8xIr4EV/A3mXTA3BP1flZ6tU=; b=TQ3irYjSghURpu+OKAp5cnBdIWl8bGYuhYo3KwMh4ymvR93jf6Pfq37yAtoXAdgT56XFvA tt06AdMQcGl3BobktZtN8txmw1ZmRztv0fMvAaXlJ+78CyBUQgARlfeEL7RLjBqmhiKpw+ bcvyQW8IsFEJ/PXo0VfPm5hkD1JRvcw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1661517254; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=RXEn1yVK7Xl+j0Wqvkg8xIr4EV/A3mXTA3BP1flZ6tU=; b=ts1e/YvoRFFLV7fSINSQC2WLu8Zb0E2IR8HGODeS1anzpg5ZWjlZ3lljbrAHsE+3f5paAs qs6tD8Uub0Hix4AQ== 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 39C2D13A7E for ; Fri, 26 Aug 2022 12:34:14 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id MyMjDca9CGMgFQAAMHmgww (envelope-from ) for ; Fri, 26 Aug 2022 12:34:14 +0000 Date: Fri, 26 Aug 2022 14:34:13 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH 2/2] Refactor init_use_preds and find_control_equiv_block MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Message-Id: <20220826123414.39C2D13A7E@imap2.suse-dmz.suse.de> X-Spam-Status: No, score=-11.7 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: The following inlines find_control_equiv_block and is_loop_exit into init_use_preds and refactors that for better readability and similarity with the post-dominator walk in compute_control_dep_chain. * gimple-predicate-analysis.cc (is_loop_exit, find_control_equiv_block): Inline into single caller ... (uninit_analysis::init_use_preds): ... here and refactor. --- gcc/gimple-predicate-analysis.cc | 55 ++++++++++---------------------- 1 file changed, 16 insertions(+), 39 deletions(-) diff --git a/gcc/gimple-predicate-analysis.cc b/gcc/gimple-predicate-analysis.cc index 934e9516e7b..e388bb37685 100644 --- a/gcc/gimple-predicate-analysis.cc +++ b/gcc/gimple-predicate-analysis.cc @@ -59,33 +59,6 @@ for the case corresponding to an edge. */ #define MAX_SWITCH_CASES 40 -/* Return true if, when BB1 is postdominating BB2, BB1 is a loop exit. */ - -static bool -is_loop_exit (basic_block bb2, basic_block bb1) -{ - return single_pred_p (bb1) && !single_succ_p (bb2); -} - -/* Find BB's closest postdominator that is its control equivalent (i.e., - that's controlled by the same predicate). */ - -static inline basic_block -find_control_equiv_block (basic_block bb) -{ - basic_block pdom = get_immediate_dominator (CDI_POST_DOMINATORS, bb); - - /* Skip the postdominating bb that is also a loop exit. */ - if (is_loop_exit (bb, pdom)) - return NULL; - - /* If the postdominator is dominated by BB, return it. */ - if (dominated_by_p (CDI_DOMINATORS, pdom, bb)) - return pdom; - - return NULL; -} - /* Return true if X1 is the negation of X2. */ static inline bool @@ -1991,25 +1964,29 @@ bool uninit_analysis::init_use_preds (predicate &use_preds, basic_block def_bb, basic_block use_bb) { - gcc_assert (use_preds.is_empty ()); + gcc_assert (use_preds.is_empty () + && dominated_by_p (CDI_DOMINATORS, use_bb, def_bb)); /* Set CD_ROOT to the basic block closest to USE_BB that is the control equivalent of (is guarded by the same predicate as) DEF_BB that also - dominates USE_BB. */ + dominates USE_BB. This mimics the inner loop in + compute_control_dep_chain. */ basic_block cd_root = def_bb; - while (dominated_by_p (CDI_DOMINATORS, use_bb, cd_root)) + do { - /* Find CD_ROOT's closest postdominator that's its control - equivalent. */ - if (basic_block bb = find_control_equiv_block (cd_root)) - if (dominated_by_p (CDI_DOMINATORS, use_bb, bb)) - { - cd_root = bb; - continue; - } + basic_block pdom = get_immediate_dominator (CDI_POST_DOMINATORS, cd_root); - break; + /* Stop at a loop exit which is also postdominating cd_root. */ + if (single_pred_p (pdom) && !single_succ_p (cd_root)) + break; + + if (!dominated_by_p (CDI_DOMINATORS, pdom, cd_root) + || !dominated_by_p (CDI_DOMINATORS, use_bb, pdom)) + break; + + cd_root = pdom; } + while (1); /* Set DEP_CHAINS to the set of edges between CD_ROOT and USE_BB. Each DEP_CHAINS element is a series of edges whose conditions -- 2.35.3