From patchwork Mon Apr 17 22:17:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 84490 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2435635vqo; Mon, 17 Apr 2023 15:18:48 -0700 (PDT) X-Google-Smtp-Source: AKy350bnI9ILC67zbIPlR7LOi5Q5/pPwZDwTDc47bm+UFaxwMzsuA17nMHNPOirvMPoZ4vlPegVI X-Received: by 2002:a17:906:3d31:b0:94d:8b66:46d1 with SMTP id l17-20020a1709063d3100b0094d8b6646d1mr8231923ejf.6.1681769928403; Mon, 17 Apr 2023 15:18:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681769928; cv=none; d=google.com; s=arc-20160816; b=b0jWSn8ANLiW4skvZK3hi979aFmqW1UxBSDBePvf+zUvC/eT84e+G+uZY69cREeoDz i81ACreJ46v4Id+Ht7ke16MPWGl28bH263FUBXLYqGRFwvP/BJ68gdz4MB61rTAgDAzd L6YS7YipLkVaxn46yPZ1M6/nOgxtMKTROYe0wyJof5XbbU4UbMSxOH2tifTkPgkGglIG J1HgLH6L8dIfm7cBdamHkgwJVkAjBNB/h268MyuhTk8RnqccMdfSdUJN5S/0M4zTk526 PfSHKPsd9obTCWvfX4sWltBt0vDXIYVdtz7DELQUDigaJ0xDpB+KOdTK30/vwQoFk/lU x2+w== 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 :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=ezFgVU1W45UwSgLyTIkxrkfN16DBSdwyBzgLS0xnaEY=; b=huJZacSGzl/zBOM5JZTYw+I8yILoww6rZmx0owKVMEiaQu4POnj3KVX/bFA2zIJ4ej uX+mc0/NkYm1g77kMOF6YrTq/W3mPBDxGRtYKfAQ3+JuPgU1KnzvpcGAY+hVa6FoY52W MUyGn+LAO8kkeYTzKzTvZqdy9oFJfvyFmNqwZnlJWqnwlhASoWHdrc0Acjk6MwpjVpSA jyyo6kFixDJMTrmA8rs3Z3MPW9xyruX/q/mEvX9l170w8F44iqulcUJoJ3c5sCLc/ed2 ndQdOurK3Q2RbJladMt+k1ONTInXbmnHdBrlRL55pjk5RfmQRXmPGgP6DeYWKkjZYfnN RyUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=FhQxt1tP; 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 gj36-20020a170907742400b0094e61ea185dsi2562789ejc.433.2023.04.17.15.18.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 15:18:48 -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=FhQxt1tP; 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 691393857038 for ; Mon, 17 Apr 2023 22:18:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 691393857038 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1681769919; bh=ezFgVU1W45UwSgLyTIkxrkfN16DBSdwyBzgLS0xnaEY=; h=To:CC:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=FhQxt1tPE8jpBf4HLbDEN25YzDmED1yNzxgqmqhrbqIHrn8PdiKatdujgqBaGP7hX pc5rppMYkh0xx1AOiwoFTYK09UUd/quqWt1n/mQuymEWAd8U6DGpLKvlOjczr7OXjB nY6QVtkszzx8BsLmJddDW86qd+RJaEOL7j38f000= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by sourceware.org (Postfix) with ESMTPS id D931A3858C50 for ; Mon, 17 Apr 2023 22:17:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D931A3858C50 Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 33HM1MGU005254 for ; Mon, 17 Apr 2023 15:17:52 -0700 Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3pyuenm7bw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Mon, 17 Apr 2023 15:17:52 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Mon, 17 Apr 2023 15:17:50 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Mon, 17 Apr 2023 15:17:50 -0700 Received: from vpnclient.wrightpinski.org.com (unknown [10.69.242.187]) by maili.marvell.com (Postfix) with ESMTP id AC3B95B6946; Mon, 17 Apr 2023 15:17:49 -0700 (PDT) To: CC: Andrew Pinski Subject: [PATCH 1/2] PHIOPT: small cleanup in match_simplify_replacement Date: Mon, 17 Apr 2023 15:17:39 -0700 Message-ID: <20230417221740.251864-1-apinski@marvell.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Proofpoint-GUID: XjRdGVwY5F3aUCLvmbuV8K4jbD-Z26zr X-Proofpoint-ORIG-GUID: XjRdGVwY5F3aUCLvmbuV8K4jbD-Z26zr X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-17_14,2023-04-17_01,2023-02-09_01 X-Spam-Status: No, score=-14.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, 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: Andrew Pinski via Gcc-patches From: Andrew Pinski Reply-To: Andrew Pinski 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?1763463584362284547?= X-GMAIL-MSGID: =?utf-8?q?1763463584362284547?= We know that the statement we are moving is already have a SSA_NAME on the lhs so we don't need to check that and can also just call reset_flow_sensitive_info with the name we already got. OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. gcc/ChangeLog: * tree-ssa-phiopt.cc (match_simplify_replacement): Simplify code that does the movement slightly. --- gcc/tree-ssa-phiopt.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc index 16acd2f1894..4ddb4d5db90 100644 --- a/gcc/tree-ssa-phiopt.cc +++ b/gcc/tree-ssa-phiopt.cc @@ -1094,11 +1094,10 @@ match_simplify_replacement (basic_block cond_bb, basic_block middle_bb, tree name = gimple_get_lhs (stmt_to_move); // Mark the name to be renamed if there is one. - if (name && TREE_CODE (name) == SSA_NAME) - bitmap_set_bit (inserted_exprs, SSA_NAME_VERSION (name)); + bitmap_set_bit (inserted_exprs, SSA_NAME_VERSION (name)); gimple_stmt_iterator gsi1 = gsi_for_stmt (stmt_to_move); gsi_move_before (&gsi1, &gsi); - reset_flow_sensitive_info (gimple_assign_lhs (stmt_to_move)); + reset_flow_sensitive_info (name); } replace_phi_edge_with_variable (cond_bb, e1, phi, result, inserted_exprs); From patchwork Mon Apr 17 22:17:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 84491 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2435682vqo; Mon, 17 Apr 2023 15:18:54 -0700 (PDT) X-Google-Smtp-Source: AKy350YdugJBpGiLFag9cwKPj+tdIywim1asUhq8djmpMHyIGsi4N9gMKXWpJa+89EmgCNEyl4hE X-Received: by 2002:a17:906:70d1:b0:94e:e859:8721 with SMTP id g17-20020a17090670d100b0094ee8598721mr10700020ejk.22.1681769934415; Mon, 17 Apr 2023 15:18:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681769934; cv=none; d=google.com; s=arc-20160816; b=d2Iqkmx103C8LMFFhSdSxtZNmDoVaNF5RWD9G15EPUWq7vXDH2QzS37kKTfxc2IzPo csMz09aQ1W6ZnfYvurAuGA+3C+cfP9/kp33kvY+P33UVBgbcbwQcslYGIDnuC6Bxu3pO boG2wZUrIYkISuwXE5Xc2F2lhQXPZ5qzfE9nlz56dNvAheXvVe5b6U9tuM346EIQ2v1o SfflIODop2nKarPPQZbLpjpyuc+0b7Mdtck2oqrhMeaaGmEkM/LeiCB1reogij/Wi4Rt vIXELs7v+Cf0RoM2GY8vtsp2elGfxaOrJtZaMmoAF2BoGzC7BDjdr2+h1U8obhQNqBbS VsKw== 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 :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=2QVj25MeuDaBF94cJ1kRiT2G0T3mRzPGb+m0hRWN/h8=; b=ru5S9pMq/fMeQSngqLw01Locacl2mHcETIwhOryDMUbmkq+b3ZgmXldqLj0sJ1PP3W 5rdY5uQ+DCrDOtHf+VPROXiPwfHl7H+39KHfxi/9woq3qyiBSb7hzCpYrxzfDlK5+Y59 XWEXEz1YkASTQdF2tlcEpr3dyPd67YR8lmw+OdjqjYC+5dXCs60CnpvSZXu5Cg2V1XIz 7PLU8gkQrcgq1gl6Qm6SiljVRiS7G/sl6byqu0amtJKPe5k6YGM/8jwREvEuDOc10pXx Wz0bSsGnT/gZtu7+hDWreNlIHujqJUSt85BCzkWznbA54O2NIMyoW9x25dipZM/VymZ0 bW2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=O0whNFxr; 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 jr21-20020a170906515500b009515dcbbff2si479324ejc.683.2023.04.17.15.18.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 15:18:54 -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=O0whNFxr; 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 149773857722 for ; Mon, 17 Apr 2023 22:18:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 149773857722 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1681769922; bh=2QVj25MeuDaBF94cJ1kRiT2G0T3mRzPGb+m0hRWN/h8=; h=To:CC:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=O0whNFxrVmifVPU1UxG+SH3fy52zzpG8KYGRBfQw7M5qyOKezLoTzIWtSSRieAuzq SVrBRbTZdW6FJrPvIvMXf7DixW5pFf9MwQppxBRgZ4sxYJrq2YSX5UwjaxMnS1oiTU l1XBAjiAR/862UziFmk7rLC3py5QUoC0x3PdqWrY= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by sourceware.org (Postfix) with ESMTPS id 2FD363858C53 for ; Mon, 17 Apr 2023 22:17:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2FD363858C53 Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 33HM0eHn003511 for ; Mon, 17 Apr 2023 15:17:52 -0700 Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3pyuenm7by-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Mon, 17 Apr 2023 15:17:52 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Mon, 17 Apr 2023 15:17:50 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Mon, 17 Apr 2023 15:17:50 -0700 Received: from vpnclient.wrightpinski.org.com (unknown [10.69.242.187]) by maili.marvell.com (Postfix) with ESMTP id 2530E5C68E1; Mon, 17 Apr 2023 15:17:50 -0700 (PDT) To: CC: Andrew Pinski Subject: [PATCH 2/2] PHIOPT: add folding/simplification detail to the dump Date: Mon, 17 Apr 2023 15:17:40 -0700 Message-ID: <20230417221740.251864-2-apinski@marvell.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230417221740.251864-1-apinski@marvell.com> References: <20230417221740.251864-1-apinski@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: -ROyPolDwKFmi4ekLF7gkwTJaitNDUgJ X-Proofpoint-ORIG-GUID: -ROyPolDwKFmi4ekLF7gkwTJaitNDUgJ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-17_14,2023-04-17_01,2023-02-09_01 X-Spam-Status: No, score=-14.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, 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: Andrew Pinski via Gcc-patches From: Andrew Pinski Reply-To: Andrew Pinski 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?1763463590743731577?= X-GMAIL-MSGID: =?utf-8?q?1763463590743731577?= While debugging PHI-OPT with match-and-simplify, I found that adding more dumping to the debug dumps made it easier to understand what was going on rather than stepping in the debugger so this adds them. Note I used TDF_FOLDING rather than TDF_DETAILS as these debug messages can be chatty and only needed if you are debugging match and simplify with PHI-OPT and match and simplify uses TDF_FOLDING as its check. OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. gcc/ChangeLog: * tree-ssa-phiopt.cc (gimple_simplify_phiopt): Dump the expression that is being tried when TDF_FOLDING is true. (phiopt_worker::match_simplify_replacement): Dump the sequence which was created by gimple_simplify_phiopt when TDF_FOLDING is true. --- gcc/tree-ssa-phiopt.cc | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc index 4ddb4d5db90..616b5778602 100644 --- a/gcc/tree-ssa-phiopt.cc +++ b/gcc/tree-ssa-phiopt.cc @@ -916,6 +916,18 @@ gimple_simplify_phiopt (bool early_p, tree type, gimple *comp_stmt, "a != 0". */ tree cond = build2_loc (loc, comp_code, boolean_type_node, cmp0, cmp1); + + if (dump_file && (dump_flags & TDF_FOLDING)) + { + fprintf (dump_file, "\nphiopt match-simplify trying:\n\t"); + print_generic_expr (dump_file, cond); + fprintf (dump_file, " ? "); + print_generic_expr (dump_file, arg0); + fprintf (dump_file, " : "); + print_generic_expr (dump_file, arg1); + fprintf (dump_file, "\n"); + } + gimple_match_op op (gimple_match_cond::UNCOND, COND_EXPR, type, cond, arg0, arg1); @@ -947,6 +959,18 @@ gimple_simplify_phiopt (bool early_p, tree type, gimple *comp_stmt, cond = build2_loc (loc, comp_code, boolean_type_node, cmp0, cmp1); + + if (dump_file && (dump_flags & TDF_FOLDING)) + { + fprintf (dump_file, "\nphiopt match-simplify trying:\n\t"); + print_generic_expr (dump_file, cond); + fprintf (dump_file, " ? "); + print_generic_expr (dump_file, arg1); + fprintf (dump_file, " : "); + print_generic_expr (dump_file, arg0); + fprintf (dump_file, "\n"); + } + gimple_match_op op1 (gimple_match_cond::UNCOND, COND_EXPR, type, cond, arg1, arg0); @@ -1078,6 +1102,11 @@ match_simplify_replacement (basic_block cond_bb, basic_block middle_bb, if (name && TREE_CODE (name) == SSA_NAME) bitmap_set_bit (inserted_exprs, SSA_NAME_VERSION (name)); } + if (dump_file && (dump_flags & TDF_FOLDING)) + { + fprintf (dump_file, "Folded into the sequence:\n"); + print_gimple_seq (dump_file, seq, 0, TDF_VOPS|TDF_MEMSYMS); + } gsi_insert_seq_before (&gsi, seq, GSI_CONTINUE_LINKING); }