From patchwork Thu Aug 11 11:42:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 470 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6a10:38f:b0:2d5:3c95:9e21 with SMTP id 15csp155779pxh; Thu, 11 Aug 2022 04:43:02 -0700 (PDT) X-Google-Smtp-Source: AA6agR70DkchuJrgozMwcBs39gpJiUtopU+t9dKaJQO6kZSBV1x8n1jLU+M0ekER9QDBLrEfaUO+ X-Received: by 2002:a17:907:1629:b0:730:7d10:639c with SMTP id hb41-20020a170907162900b007307d10639cmr22614226ejc.256.1660218182235; Thu, 11 Aug 2022 04:43:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660218182; cv=none; d=google.com; s=arc-20160816; b=enyQhbCQPAdZqtUBBWIXllcv29VDnm/tMQ5cMicKRFStdGa5WwjGPooLUbzhlzyF7T yJUKTqE5F0jWCsEvCmOtSau9xRWyShsti9RlrdiW5CxxLyzXx8cU8VeKd5n3wsCvog8c qFg2jYTUiX3895JDtw+uhtf27EEtw4rcP2QSVMvQfJCmVYRpiNQ/PmDZYgIqq+l1Rj7M 3JrnhWMTr/47ob5s5pI/iA2iSAs64C3XPztM8DV+kggTZ4HC7pfW9NYKK4KrWN4kC//o 6L9VJXTgE6j5ssVT14aQO5Ltza2dEgJJo5WKvUzrg8do4Ecxex00zA7gc5q6CPbHm6gy pwhg== 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=OChHIcRqZqtwH/72xz98oAcgAlQfyXeOOAtAZEZEkMo=; b=hParM2W14mkvTlaRUgxSocZXP+nVI9JLYBGxCJf6+zYB3Vr+FI5PKuXQSNdDScQvWd f2rw/bxkDWn9QQOH+naIqAJaJsjkjtMTwsDg12No4Ti3DOt3TfneXjBIE0TT9qO9KhzP czGBRClESp5fC5oy6oTsj5eVvWCT7TSwXvJXOpvCik+xEq7zBMMUO4QdQTVOedKUxwqY PNAdFxDs7HQMEIqyrJAZcWNlpUlMB9aqFgK5l01rYn+7WKSn+YnIOb5dhSbf6Bk3K9OG dsl2HZvv3p38pzSLKlmLBTBvaa30eoj3iRkZtcDIgS3pPF5HEcxIjRRY4/X158Kg3cWx aSfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=EV384dj8; 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 qw39-20020a1709066a2700b0073160e4227csi7951349ejc.489.2022.08.11.04.43.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Aug 2022 04:43:02 -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=EV384dj8; 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 CB864385AC2E for ; Thu, 11 Aug 2022 11:43:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CB864385AC2E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1660218180; bh=OChHIcRqZqtwH/72xz98oAcgAlQfyXeOOAtAZEZEkMo=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=EV384dj8Z24vlBTZLGhJmejcBA12WGcWLNtV1D5D9Iln2b8Qx4VAHEt5b3JiVrhgx 7nRBGdTJyRB8aotsnicmDX1n92BnIUtd1hvFCHUUXmNzsQrVA4luK73pVYFEdkpg/B Tohp/BstDGqpZN2XdNDQkZIk+sZeAsk5NlJO9Lks= 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 3CD623858429 for ; Thu, 11 Aug 2022 11:42:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3CD623858429 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id F379C33A28; Thu, 11 Aug 2022 11:42:16 +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 07AFE2C22A; Thu, 11 Aug 2022 11:42:11 +0000 (UTC) Date: Thu, 11 Aug 2022 11:42:16 +0000 (UTC) To: gcc-patches@gcc.gnu.org Subject: [PATCH] Tame path_range_query::compute_imports 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: <20220811114300.CB864385AC2E@sourceware.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1740864940671415886?= X-GMAIL-MSGID: =?utf-8?q?1740864940671415886?= This avoids going BBs outside of the path when adding def chains to the set of imports. It also syncs the code with range_def_chain::get_def_chain to not miss out on some imports this function would identify. Bootstrap / regtest pending on x86_64-unknown-linux-gnu. The question still stands on what the path_range_query::compute_ranges actually needs in its m_imports - at least I don't easily see how the range-folds will use the path range cache or be path sensitive at all. OK? Thanks, Richard. * gimple-range-path.cc (path_range_query::compute_imports): Restrict walking SSA defs to blocks inside the path. Track the same operands as range_def_chain::get_def_chain does. --- gcc/gimple-range-path.cc | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/gcc/gimple-range-path.cc b/gcc/gimple-range-path.cc index 5ae374df3a2..5ff2c733b4e 100644 --- a/gcc/gimple-range-path.cc +++ b/gcc/gimple-range-path.cc @@ -575,18 +575,11 @@ path_range_query::compute_imports (bitmap imports, const vec &path) { tree name = worklist.pop (); gimple *def_stmt = SSA_NAME_DEF_STMT (name); + if (SSA_NAME_IS_DEFAULT_DEF (name) + || !path.contains (gimple_bb (def_stmt))) + continue; - if (is_gimple_assign (def_stmt)) - { - add_to_imports (gimple_assign_rhs1 (def_stmt), imports); - tree rhs = gimple_assign_rhs2 (def_stmt); - if (rhs && add_to_imports (rhs, imports)) - worklist.safe_push (rhs); - rhs = gimple_assign_rhs3 (def_stmt); - if (rhs && add_to_imports (rhs, imports)) - worklist.safe_push (rhs); - } - else if (gphi *phi = dyn_cast (def_stmt)) + if (gphi *phi = dyn_cast (def_stmt)) { for (size_t i = 0; i < gimple_phi_num_args (phi); ++i) { @@ -599,6 +592,30 @@ path_range_query::compute_imports (bitmap imports, const vec &path) worklist.safe_push (arg); } } + else if (gassign *ass = dyn_cast (def_stmt)) + { + tree ssa[3]; + if (range_op_handler (ass)) + { + ssa[0] = gimple_range_ssa_p (gimple_range_operand1 (ass)); + ssa[1] = gimple_range_ssa_p (gimple_range_operand2 (ass)); + ssa[2] = NULL_TREE; + } + else if (gimple_assign_rhs_code (ass) == COND_EXPR) + { + ssa[0] = gimple_range_ssa_p (gimple_assign_rhs1 (ass)); + ssa[1] = gimple_range_ssa_p (gimple_assign_rhs2 (ass)); + ssa[2] = gimple_range_ssa_p (gimple_assign_rhs3 (ass)); + } + else + continue; + for (unsigned j = 0; j < 3; ++j) + { + tree rhs = ssa[j]; + if (rhs && add_to_imports (rhs, imports)) + worklist.safe_push (rhs); + } + } } // Exported booleans along the path, may help conditionals. if (m_resolve)