From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=marvell.com 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=/wal+vyLNZ4cg5RW9Yn0qr/PCrpsdmzHdtbkeD5ZBd4=; b=JWxLFmv6H9REDZdYvu3fswFDhWqHFNwpUby9oGg0e4bb6/KjE8x4QtMQW+IYFT8jaLQA 1QWguygcdBl4RundOWrM3/nFdDlfJYlJNcCp/CaD4G6iMRFyLj24RGJcp6TaKRrxdChZ z2SvGXJcwji3VthSEsATcANo1XezTtCLSAn4Ls0hzhuLSHWNa551BQPut7uT3P8q3xZc XPhUu/cjoZl80uv+xWbla62J1s9J1PVD+6ogLIafa5cK7lXnZSZfDlh0MI5WrKX4I439 HIa9T07qyj7MMZ4fz6eHuWy7nYhyeprBDB8PPD3oqMoWHSY/J60h2FNJX1/YSz0DmCRl VA== 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) From: Andrew Pinski 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 Content-Transfer-Encoding: 8bit Content-Type: text/plain 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 List-Id: 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); } -- 2.31.1