From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by sourceware.org (Postfix) with ESMTPS id EF3FC3858C1F for ; Sun, 30 Apr 2023 21:13:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EF3FC3858C1F 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 (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 33UKslxM031534 for ; Sun, 30 Apr 2023 14:13:36 -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=iypJl7fn714t+fSzdOPmISubYMZpVp/JLgKyGxmIfLE=; b=hQU7twM+aas3ACNqs4rgL/dMI3QWZaFeChpT+za/bVwlZvqReAhPO5OsU39YigW5AdFv J8OzqhYsGQjLIEAK2HciKExikcbFICMyZjdiYAHbLs9SaRxGrbOxzBUuGVPSS+A67Deq kwYA4TSdBIn5vX+cywqZh6T8fOPi2svTUJsrXdFTIJS3lSL+L47QiJ14MViJ9skNK/O7 9lCcopdnmYOpRj10Or2HRyvXwgdcwwsuX9zcIUpaP2SJsSlDoE7jtJpBMswl/9OHT0zS +F6ZI4syaTuzfk2A5wsWrCJLRA3SBQ47GBAAxud+4b8UQhIneUht+pIaV1/FlmBvD8Tz /A== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3q92rnubp9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Sun, 30 Apr 2023 14:13:36 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Sun, 30 Apr 2023 14:13:34 -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; Sun, 30 Apr 2023 14:13:34 -0700 Received: from vpnclient.wrightpinski.org.com (unknown [10.69.242.187]) by maili.marvell.com (Postfix) with ESMTP id 1AA363F70AA; Sun, 30 Apr 2023 14:13:34 -0700 (PDT) From: Andrew Pinski To: CC: Andrew Pinski Subject: [PATCH] PHIOPT: small refactoring of match_simplify_replacement. Date: Sun, 30 Apr 2023 14:13:30 -0700 Message-ID: <20230430211330.761973-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-ORIG-GUID: fsmItYXJJzOorExTNn8Y1BQQvbIUVipP X-Proofpoint-GUID: fsmItYXJJzOorExTNn8Y1BQQvbIUVipP 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-30_08,2023-04-27_01,2023-02-09_01 X-Spam-Status: No, score=-14.5 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 List-Id: When I added diamond shaped form bb to match_simplify_replacement, I copied the code to move the statement rather than factoring it out to a new function. This does the refactoring to a new function to avoid the duplicated code. It will make adding support for having two statements to move easier (the second statement will only be a conversion). OK? Bootstrapped and tested on x86_64-linux-gnu. gcc/ChangeLog: * tree-ssa-phiopt.cc (move_stmt): New function. (match_simplify_replacement): Use move_stmt instead of the inlined version. --- gcc/tree-ssa-phiopt.cc | 57 ++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 33 deletions(-) diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc index 024a4362093..65b3deea34a 100644 --- a/gcc/tree-ssa-phiopt.cc +++ b/gcc/tree-ssa-phiopt.cc @@ -643,6 +643,28 @@ empty_bb_or_one_feeding_into_p (basic_block bb, return true; } +/* Move STMT to before GSI and insert its defining + name into INSERTED_EXPRS bitmap. */ +static void +move_stmt (gimple *stmt, gimple_stmt_iterator *gsi, auto_bitmap &inserted_exprs) +{ + if (!stmt) + return; + if (dump_file && (dump_flags & TDF_DETAILS)) + { + fprintf (dump_file, "statement un-sinked:\n"); + print_gimple_stmt (dump_file, stmt, 0, + TDF_VOPS|TDF_MEMSYMS); + } + + tree name = gimple_get_lhs (stmt); + // Mark the name to be renamed if there is one. + bitmap_set_bit (inserted_exprs, SSA_NAME_VERSION (name)); + gimple_stmt_iterator gsi1 = gsi_for_stmt (stmt); + gsi_move_before (&gsi1, gsi); + reset_flow_sensitive_info (name); +} + /* The function match_simplify_replacement does the main work of doing the replacement using match and simplify. Return true if the replacement is done. Otherwise return false. @@ -727,39 +749,8 @@ match_simplify_replacement (basic_block cond_bb, basic_block middle_bb, /* If there was a statement to move, move it to right before the original conditional. */ - if (stmt_to_move) - { - if (dump_file && (dump_flags & TDF_DETAILS)) - { - fprintf (dump_file, "statement un-sinked:\n"); - print_gimple_stmt (dump_file, stmt_to_move, 0, - TDF_VOPS|TDF_MEMSYMS); - } - - tree name = gimple_get_lhs (stmt_to_move); - // Mark the name to be renamed if there is one. - 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 (name); - } - - if (stmt_to_move_alt) - { - if (dump_file && (dump_flags & TDF_DETAILS)) - { - fprintf (dump_file, "statement un-sinked:\n"); - print_gimple_stmt (dump_file, stmt_to_move_alt, 0, - TDF_VOPS|TDF_MEMSYMS); - } - - tree name = gimple_get_lhs (stmt_to_move_alt); - // Mark the name to be renamed if there is one. - bitmap_set_bit (inserted_exprs, SSA_NAME_VERSION (name)); - gimple_stmt_iterator gsi1 = gsi_for_stmt (stmt_to_move_alt); - gsi_move_before (&gsi1, &gsi); - reset_flow_sensitive_info (name); - } + move_stmt (stmt_to_move, &gsi, inserted_exprs); + move_stmt (stmt_to_move_alt, &gsi, inserted_exprs); replace_phi_edge_with_variable (cond_bb, e1, phi, result, inserted_exprs); -- 2.31.1