From patchwork Mon Sep 5 12:47:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 993 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5044:0:0:0:0:0 with SMTP id h4csp160193wrt; Mon, 5 Sep 2022 05:48:03 -0700 (PDT) X-Google-Smtp-Source: AA6agR7cTpLW8WJwbW+b92C/dmB/izeWuLjZcJL2GxV4sG87RY3V7pAOdYN21bciqpxVRqXbpAtC X-Received: by 2002:a05:6402:51d1:b0:44b:ea34:6c0a with SMTP id r17-20020a05640251d100b0044bea346c0amr13566848edd.369.1662382083765; Mon, 05 Sep 2022 05:48:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662382083; cv=none; d=google.com; s=arc-20160816; b=v/O+fghdn9QwYFW0udUoTPcjsllcGeGFam9dLeou1ESdMFMqkDroK3n74RRFCpN+84 SHpYY3//iap/oGQOLYjquUb6ObbCw6u3D0qssTjYDiaauxfEO5qcNGtzI2vqzSJnmd7L +zTYtM7W8pOP6zakmRbVvstdn3SyLYTaGlGPG+0S9opsQytRQZmbLFoJfNEfD0bnGsrz qfXYzCN+SeI3NRcn3xf22+G7XSluvMudGjJKMwDKbQOXd0dT80/am+cYQHr5WZop/zS0 j0nF4PO1dxe8G9ZgPWlC0QuuHD5X6VMqWHkIMa+y7UuYYLYrhvS/Isw03+nJ2AK96vET BrGw== 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=h7OlwApEFKv9W5swU/TjzTLin5UH6IEOyRXydMNqmIY=; b=H7yOlOEIsKlqVQhEPWS4FKJmVEuPh/gqynsNMjBYGge1ocfk2uo89MJORwyWYk7W38 NN/xJSZNtcolAvnc9EewGD0J3q2V/Xvz2sEiipnCtTY36LdIdiVspA/RASln7G1MDSNa TV7RMqtjL64uG235kmUNg7herZtuh4k4CoCuzp4IbRvBtNeDH94J0A8BzZaisOSK9KKz CoY5FOYrXIfJgpLT+t7Hc0vLL6vy9OBOuS7uC732uR+APy3VE1B7nm4CG3Hn592MwbdJ Q5Kz/PYQFZpJ8M5PbyiG+fKIa+zJp8ZW6CoAiOL4JjGMZiCaBHnSqysYM8bVkLtAHVjX 5m4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=RUFXxR9C; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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. [8.43.85.97]) by mx.google.com with ESMTPS id f8-20020a056402354800b0043d5bcf8553si8498092edd.95.2022.09.05.05.48.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Sep 2022 05:48:03 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=RUFXxR9C; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 64C213856262 for ; Mon, 5 Sep 2022 12:47:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 64C213856262 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662382077; bh=h7OlwApEFKv9W5swU/TjzTLin5UH6IEOyRXydMNqmIY=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=RUFXxR9CMKgeOL1j5bUVKkPdJwvHXdL/ET/VYBETIS1q6e97wsIzFbGInohX1m980 YYuItIXSHn3DU2DkuOZZOO0PZisiS7R+jAz6QG4jvjxGW594LkR6cNMDEYzCDwwlEH TQrxtqwIuAk43nZf5LeBZYaG1JjHcTTMzSegF07I= 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 B2A9C385AC3F for ; Mon, 5 Sep 2022 12:47:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B2A9C385AC3F 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 9350D5FD9A for ; Mon, 5 Sep 2022 12:47:13 +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 8432013A66 for ; Mon, 5 Sep 2022 12:47:13 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id UgpnH9HvFWNWDAAAMHmgww (envelope-from ) for ; Mon, 05 Sep 2022 12:47:13 +0000 Date: Mon, 5 Sep 2022 14:47:13 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [PATCH] Unify MAX_POSTDOM_CHECK and --param uninit-control-dep-attempts MIME-Version: 1.0 Message-Id: <20220905124713.8432013A66@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?1743133956094118464?= X-GMAIL-MSGID: =?utf-8?q?1743133956094118464?= The following unifies both limits, in particular the MAX_POSTDOM_CHECK tends to be too low and is not user-controllable. Bootstrapped on x86_64-unknown-linux-gnu, testing in progress. Richard. * gimple-predicate-analysis.cc (MAX_POSTDOM_CHECK): Remove. (compute_control_dep_chain): Move uninit-control-dep-attempts checking where it also counts the post-dominator check invocations. --- gcc/gimple-predicate-analysis.cc | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/gcc/gimple-predicate-analysis.cc b/gcc/gimple-predicate-analysis.cc index 5629a6dc277..6684aa6c179 100644 --- a/gcc/gimple-predicate-analysis.cc +++ b/gcc/gimple-predicate-analysis.cc @@ -52,10 +52,6 @@ #define MAX_NUM_CHAINS 8 #define MAX_CHAIN_LEN 5 -/* When enumerating paths between two blocks this limits the number of - post-dominator skips between two edges possibly defining a predicate. */ -#define MAX_POSTDOM_CHECK 8 - /* The limit for the number of switch cases when we do the linear search for the case corresponding to an edge. */ #define MAX_SWITCH_CASES 40 @@ -1010,15 +1006,6 @@ compute_control_dep_chain (basic_block dom_bb, const_basic_block dep_bb, if (single_succ_p (dom_bb)) return false; - if (*num_calls > (unsigned)param_uninit_control_dep_attempts) - { - if (dump_file) - fprintf (dump_file, "param_uninit_control_dep_attempts exceeded: %u\n", - *num_calls); - return false; - } - ++*num_calls; - /* FIXME: Use a set instead. */ unsigned cur_chain_len = cur_cd_chain.length (); if (cur_chain_len > MAX_CHAIN_LEN) @@ -1048,7 +1035,6 @@ compute_control_dep_chain (basic_block dom_bb, const_basic_block dep_bb, edge_iterator ei; FOR_EACH_EDGE (e, ei, dom_bb->succs) { - int post_dom_check = 0; if (e->flags & (EDGE_FAKE | EDGE_ABNORMAL | EDGE_DFS_BACK)) continue; @@ -1088,6 +1074,17 @@ compute_control_dep_chain (basic_block dom_bb, const_basic_block dep_bb, if (in_region != 0 && !(cd_bb->flags & in_region)) break; + /* Count the number of steps we perform to limit compile-time. + This should cover both recursion and the post-dominator walk. */ + if (*num_calls > (unsigned)param_uninit_control_dep_attempts) + { + if (dump_file) + fprintf (dump_file, "param_uninit_control_dep_attempts " + "exceeded: %u\n", *num_calls); + return false; + } + ++*num_calls; + /* Check if DEP_BB is indirectly control-dependent on DOM_BB. */ if (!single_succ_p (cd_bb) && compute_control_dep_chain (cd_bb, dep_bb, cd_chains, @@ -1105,9 +1102,7 @@ compute_control_dep_chain (basic_block dom_bb, const_basic_block dep_bb, && single_succ_edge (cd_bb)->flags & EDGE_DFS_BACK) break; cd_bb = get_immediate_dominator (CDI_POST_DOMINATORS, cd_bb); - post_dom_check++; - if (cd_bb == EXIT_BLOCK_PTR_FOR_FN (cfun) - || post_dom_check > MAX_POSTDOM_CHECK) + if (cd_bb == EXIT_BLOCK_PTR_FOR_FN (cfun)) break; } cur_cd_chain.pop ();