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); }