From patchwork Sat Aug 26 02:14:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 136953 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a7d1:0:b0:3f2:4152:657d with SMTP id p17csp2162939vqm; Fri, 25 Aug 2023 19:16:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHQ2t5KySoJl/xr6JluL2jsizBMzVE9M47f/DjXy9AWf5jAtnJMfujBYkHH7gk8QHGukQ+x X-Received: by 2002:a17:907:628f:b0:9a1:ad4b:f9e9 with SMTP id nd15-20020a170907628f00b009a1ad4bf9e9mr14745644ejc.32.1693016162548; Fri, 25 Aug 2023 19:16:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693016162; cv=none; d=google.com; s=arc-20160816; b=oEtEckG8Nm6nt8xiGZMlf52EH8iO9B51AujuD5nqFIPAKWY2KKGYcM+4t1pokSzcX7 Fofgp4Vn5Unp87LiPm3Zpt8z39mTw6jliesv767nKfhBL8US+YjKzlrh1/oWRImbT5Q8 G7V8rNNeG0A9tudOwpIkgi7GdgwAY+gtymwciPTiZgt1pgcZzuqdVai6orUYFRCzvbhq pUMwQfpGP88qCAAh4XDBCViMxt1tmLooRWYvcagMpNuVQ/pugHPYRxJUcBRXR3kAEtW8 wDGYtSehhRp8SSPSbSWvyTTNmV6Iq3hqF8E9J5t8zRPM9kXYuznaUCwtTJlky3KWRyxo 93iQ== 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=/wal+vyLNZ4cg5RW9Yn0qr/PCrpsdmzHdtbkeD5ZBd4=; fh=XbcmRug6/SzczusyoNU1I7Lu5oY0AN2u0mWDzKoxdSs=; b=QJdesDmWnDdNW+FfvdHE08ARLMRCirznOruBs6h9cNqBK4hfWG/JP8xiubsMZIBhIB vScsyQlcmrW1iqf6aVZ+qJtcbkSssb2KRkUBUc+HLzQOb+d2hx6iuJOtsGcRQfog9evT TV88NB3yFpgyNTjkhmxH53y5AD3y2GHK6DQXyqDcDNAcvHgMSsTezJD8DL0c3qdlukwX 99pqlOJg2Dlcd7+S0QhEtXcs1zLwLQgPCmBaliCXE337hZ2T+1VMb3Ep8KqsCOXvaDyT mUnw77XWpbN0gJRyyBKNg+QEj995lvlPwPQRypfBcRHGBWTIXPPeGaBbL/WVEKGWGirg R/8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=JtTgzwpJ; 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 (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id x18-20020a170906805200b009655fcff588si1719779ejw.835.2023.08.25.19.16.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Aug 2023 19:16:02 -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=JtTgzwpJ; 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 787F33858D37 for ; Sat, 26 Aug 2023 02:16:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 787F33858D37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1693016161; bh=/wal+vyLNZ4cg5RW9Yn0qr/PCrpsdmzHdtbkeD5ZBd4=; h=To:CC:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=JtTgzwpJPireRnj4k8Z2xkUV7pXcG9m81pGvrKyYihgY/Olv8uvp37hZ2YiSXhJ99 FeJOtDP4FgDKTThUFmYmWaBY4YVwRITPXxIpi1dGB/p7DqjtL9jUIS1UPZ171yM52H 8Ak3ECMqI8Dc41BmL4+Rac2VoAl6h09lcG/TbTVY= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by sourceware.org (Postfix) with ESMTPS id 5F4B63858C53 for ; Sat, 26 Aug 2023 02:15:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5F4B63858C53 Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 37PHeCNZ025590 for ; Fri, 25 Aug 2023 19:15:05 -0700 Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3spmgvunp2-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Fri, 25 Aug 2023 19:15:05 -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; Fri, 25 Aug 2023 19:15:03 -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; Fri, 25 Aug 2023 19:15:03 -0700 Received: from vpnclient.wrightpinski.org.com (unknown [10.69.242.187]) by maili.marvell.com (Postfix) with ESMTP id 398CF3F70AC; Fri, 25 Aug 2023 19:15:03 -0700 (PDT) To: CC: Andrew Pinski Subject: [PATCH] PHIOPT: Add dump for match and simplify and early phiopt Date: Fri, 25 Aug 2023 19:14:58 -0700 Message-ID: <20230826021458.3624086-1-apinski@marvell.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Proofpoint-GUID: 5c9F3gd0Fw1XS6k_c52K3KsE2hCdMZsa X-Proofpoint-ORIG-GUID: 5c9F3gd0Fw1XS6k_c52K3KsE2hCdMZsa X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-08-25_19,2023-08-25_01,2023-05-22_02 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_PASS, TXREP 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: INBOX X-GMAIL-THRID: 1775256115862688641 X-GMAIL-MSGID: 1775256115862688641 This adds dump on the full result of the match-and-simplify for phiopt and specifically to know if we are rejecting something due to being in early phi-opt. OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. gcc/ChangeLog: * tree-ssa-phiopt.cc (gimple_simplify_phiopt): Add dump information when resimplify returns true. (match_simplify_replacement): Print only if accepted the match-and-simplify result rather than the full sequence. --- gcc/tree-ssa-phiopt.cc | 70 ++++++++++++++++++++++++++---------------- 1 file changed, 44 insertions(+), 26 deletions(-) diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc index 7e63fb115db..9993bbe5b76 100644 --- a/gcc/tree-ssa-phiopt.cc +++ b/gcc/tree-ssa-phiopt.cc @@ -499,7 +499,6 @@ gimple_simplify_phiopt (bool early_p, tree type, gimple *comp_stmt, tree arg0, tree arg1, gimple_seq *seq) { - tree result; gimple_seq seq1 = NULL; enum tree_code comp_code = gimple_cond_code (comp_stmt); location_t loc = gimple_location (comp_stmt); @@ -529,18 +528,29 @@ gimple_simplify_phiopt (bool early_p, tree type, gimple *comp_stmt, if (op.resimplify (&seq1, follow_all_ssa_edges)) { - /* Early we want only to allow some generated tree codes. */ - if (!early_p - || phiopt_early_allow (seq1, op)) + bool allowed = !early_p || phiopt_early_allow (seq1, op); + tree result = maybe_push_res_to_seq (&op, &seq1); + if (dump_file && (dump_flags & TDF_FOLDING)) { - result = maybe_push_res_to_seq (&op, &seq1); + fprintf (dump_file, "\nphiopt match-simplify back:\n"); + if (seq1) + print_gimple_seq (dump_file, seq1, 0, TDF_VOPS|TDF_MEMSYMS); + fprintf (dump_file, "result: "); if (result) - { - if (loc != UNKNOWN_LOCATION) - annotate_all_with_location (seq1, loc); - gimple_seq_add_seq_without_update (seq, seq1); - return result; - } + print_generic_expr (dump_file, result); + else + fprintf (dump_file, " (none)"); + fprintf (dump_file, "\n"); + if (!allowed) + fprintf (dump_file, "rejected because early\n"); + } + /* Early we want only to allow some generated tree codes. */ + if (allowed && result) + { + if (loc != UNKNOWN_LOCATION) + annotate_all_with_location (seq1, loc); + gimple_seq_add_seq_without_update (seq, seq1); + return result; } } gimple_seq_discard (seq1); @@ -572,18 +582,29 @@ gimple_simplify_phiopt (bool early_p, tree type, gimple *comp_stmt, if (op1.resimplify (&seq1, follow_all_ssa_edges)) { - /* Early we want only to allow some generated tree codes. */ - if (!early_p - || phiopt_early_allow (seq1, op1)) + bool allowed = !early_p || phiopt_early_allow (seq1, op1); + tree result = maybe_push_res_to_seq (&op1, &seq1); + if (dump_file && (dump_flags & TDF_FOLDING)) { - result = maybe_push_res_to_seq (&op1, &seq1); + fprintf (dump_file, "\nphiopt match-simplify back:\n"); + if (seq1) + print_gimple_seq (dump_file, seq1, 0, TDF_VOPS|TDF_MEMSYMS); + fprintf (dump_file, "result: "); if (result) - { - if (loc != UNKNOWN_LOCATION) - annotate_all_with_location (seq1, loc); - gimple_seq_add_seq_without_update (seq, seq1); - return result; - } + print_generic_expr (dump_file, result); + else + fprintf (dump_file, " (none)"); + fprintf (dump_file, "\n"); + if (!allowed) + fprintf (dump_file, "rejected because early\n"); + } + /* Early we want only to allow some generated tree codes. */ + if (allowed && result) + { + if (loc != UNKNOWN_LOCATION) + annotate_all_with_location (seq1, loc); + gimple_seq_add_seq_without_update (seq, seq1); + return result; } } gimple_seq_discard (seq1); @@ -855,6 +876,8 @@ match_simplify_replacement (basic_block cond_bb, basic_block middle_bb, if (!result) return false; + if (dump_file && (dump_flags & TDF_FOLDING)) + fprintf (dump_file, "accepted the phiopt match-simplify.\n"); auto_bitmap exprs_maybe_dce; @@ -881,11 +904,6 @@ match_simplify_replacement (basic_block cond_bb, basic_block middle_bb, if (name && TREE_CODE (name) == SSA_NAME) bitmap_set_bit (exprs_maybe_dce, 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); }