From patchwork Thu Sep 1 13:07:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 898 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:ecc5:0:0:0:0:0 with SMTP id s5csp243783wro; Thu, 1 Sep 2022 06:07:53 -0700 (PDT) X-Google-Smtp-Source: AA6agR6wW8jC0dP/sXCBU1lukRu9x41iQvMmLcIn0gafv7+bSbV+mPTfOibx8v6kPj1bdxLvKsRS X-Received: by 2002:a05:6402:5193:b0:43e:1d52:fd70 with SMTP id q19-20020a056402519300b0043e1d52fd70mr28636094edd.150.1662037673081; Thu, 01 Sep 2022 06:07:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662037673; cv=none; d=google.com; s=arc-20160816; b=lM39dG1JiI9bJuGcZJNoLw8S/wkfAze9jiL1gPrsHCIpQ395VO1frQoxOoeDN473Vi LfG3OmFoLn8/RPCc9Ta90olui0geT6YIYQG9M2EojpoQh7NX2VoYeHKdcHuXo+zll0yW yM1N4NopNOG/PihUuTK0jq+LS5xvUuKWepUFo9+KpMp3gyniaUXs/P8h3/oM/l493fXk car/lxbklbgXJ9/9YaSafBpa5Y+jHKqiZhdOYYxEpks/amVSmdp6pxXS0+ebV0qDwfR9 sbicbbTaltEZUPNLZq0dITLDQuu0YGFw0MKRiuLWp1xI2oXCRhV3Ouv7/B+DrN47pyuC sCRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:sender:errors-to:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mime-version:user-agent:subject:to:date:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=loTG36aRxizotOVaJhP3vqmtJZHEsAmSJ8GbIaXHntU=; b=YcWZZ1+DLZiWM1I8yMz8tJvoxF6UgvlRWua8172Y5XGZ6T6XumghSWHNnpTfqvpPkM r1iqgdt1fNKi01MHkrtEczEuVsB/+55lPQWQ7N3rFn10JfWSAb2h/a/Np9VL6kD4lu3f 3ZDjMoYVJh6Kj1zSXPeAE5DgQwOdE7ikoNpXxiTdv8APE8hiBfdwT+fyqZjWXh+GCbJN 2+MfNkpWmBqZK9BizqRpgMOsP3M8xyc0KI5A4tv3XgvvhwAe/VtApH1wEVn512BonKYq 0apYQ8bdlY6O0SXe1d5EEKUB1eD0DuRNUmkrWVFsd4xTHBkBJCOoJNXIWnH7xMqZpF9L la+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=MjqqG3JC; 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 dr5-20020a170907720500b0073d866e5d4dsi13342625ejc.98.2022.09.01.06.07.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Sep 2022 06:07:53 -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=MjqqG3JC; 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 DAC2D385829D for ; Thu, 1 Sep 2022 13:07:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DAC2D385829D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662037670; bh=loTG36aRxizotOVaJhP3vqmtJZHEsAmSJ8GbIaXHntU=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=MjqqG3JCxU3XBGczXTBDc899q15Av3gAc9YBX4aWUDZdTgfPxIpyWJrxVy4Mi2TEi VEYcy+E677eTbWEu2wHXswANh9KWYWWqycooMccZzMr9bAKIeL9rdmQUiszD61pi+Y MKnKgXKRxNnhZUha00kfj2HEXPYdsIr+n/UP4DI4= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 777F03858D1E for ; Thu, 1 Sep 2022 13:07:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 777F03858D1E Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 8092C226D3 for ; Thu, 1 Sep 2022 13:07:03 +0000 (UTC) Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 7B3362C141 for ; Thu, 1 Sep 2022 13:07:03 +0000 (UTC) Date: Thu, 1 Sep 2022 13:07:03 +0000 (UTC) To: gcc-patches@gcc.gnu.org Subject: [PATCH] Remove cycle checking from compute_control_dep_chain User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, MISSING_MID, 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" Message-Id: <20220901130750.DAC2D385829D@sourceware.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1742772815455054426?= X-GMAIL-MSGID: =?utf-8?q?1742772815455054426?= Now that we have DFS_BACK_EDGE marks we can simply avoid walking those instead of repeatedly looking for a cycle on the current chain. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. * gimple-predicate-analysis.cc (compute_control_dep_chain): Remove cycle detection, instead avoid walking backedges. --- gcc/gimple-predicate-analysis.cc | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/gcc/gimple-predicate-analysis.cc b/gcc/gimple-predicate-analysis.cc index 2982268fdfd..a754ff0a029 100644 --- a/gcc/gimple-predicate-analysis.cc +++ b/gcc/gimple-predicate-analysis.cc @@ -1035,18 +1035,6 @@ compute_control_dep_chain (basic_block dom_bb, const_basic_block dep_bb, fprintf (dump_file, "chain length exceeds 5: %u\n", cur_chain_len); } - for (unsigned i = 0; i < cur_chain_len; i++) - { - edge e = cur_cd_chain[i]; - /* Cycle detected. */ - if (e->src == dom_bb) - { - if (dump_file) - fprintf (dump_file, "cycle detected\n"); - return false; - } - } - if (DEBUG_PREDICATE_ANALYZER && dump_file) fprintf (dump_file, "%*s%s (dom_bb = %u, dep_bb = %u, cd_chains = { %s }, ...)\n", @@ -1061,7 +1049,7 @@ compute_control_dep_chain (basic_block dom_bb, const_basic_block dep_bb, FOR_EACH_EDGE (e, ei, dom_bb->succs) { int post_dom_check = 0; - if (e->flags & (EDGE_FAKE | EDGE_ABNORMAL)) + if (e->flags & (EDGE_FAKE | EDGE_ABNORMAL | EDGE_DFS_BACK)) continue; basic_block cd_bb = e->dest; @@ -1110,6 +1098,12 @@ compute_control_dep_chain (basic_block dom_bb, const_basic_block dep_bb, break; } + /* The post-dominator walk will reach a backedge only + from a forwarder, otherwise it should choose to exit + the SCC. */ + if (single_succ_p (cd_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)