From patchwork Sun Apr 30 21:13:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 88956 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2329231vqo; Sun, 30 Apr 2023 14:14:52 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ41rmCa946MaJZFCzgukt63L2/lA2fOi0A/+RF1TuOvBsemAON0+eFN1SLbWrWaY8fTlHX6 X-Received: by 2002:a17:907:1686:b0:95f:de3c:6c92 with SMTP id hc6-20020a170907168600b0095fde3c6c92mr10724698ejc.50.1682889292101; Sun, 30 Apr 2023 14:14:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682889292; cv=none; d=google.com; s=arc-20160816; b=o6ARV/9t5v56eMxdcrFhbkvA9QCQF5w7r27N1BfmUwIWucYQj/eI+FboyEWt1bbOyl POslQZUtFFEDBb9Ck93UlobvhUd6Oh9EUjPEaXKaXE/r1XARVKrbhiWhQgChxRXctA0H +eSO55dZGOUc17H4XwxFQ9BSSRjI967v/XwDokn2L4J54Pw9X+GOfmF03lAvAk3lPBwC UTo+6EUL1aI05zUb8A5jqJWkqmSdVhQHPmfgQXpiDm+ni47+SwTSlmuFTnLGJ3H8+6r9 JMM1Y3brmJ9vYmrItpZv4c0TMZT4KhU0M/Xq4vw0fXQo1q1C82WbwTqleDO7+djGxIEI 3l0g== 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=iypJl7fn714t+fSzdOPmISubYMZpVp/JLgKyGxmIfLE=; b=zsREVYDY+BJ72gIJAY6m4nPgt8Qs494XxkA1LOydZPG+Q9VEfW16pjT2hzwfszRrr+ BiL+mMD5434L+aa0v/NOihOPheuAFOwLbcPbYUw9Asb55UJS9lXOBZCJN2us30WW0mpL hCIlXF4R/8GNCib4vUrfUq/cF7OU3wFJ+gyETklV5wcxqc+Vof4CEOFfJSV+9UCh+DI3 +9wF7fKnDygmx+HsQtLIpuX7W/faQ/YN+KedpApbVtyAglpl16MMTalwv/LInpN5BEdG dRoLNvD2DMDGdHcEZ1faCQsxmrfO+Sz53G/d/bDmYz0x53Gy26GZbCBFKLifJI/ZVdOl nGag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=h2ZgkSOX; 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 (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id dx22-20020a170906a85600b0094fadb2171dsi19818135ejb.252.2023.04.30.14.14.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Apr 2023 14:14:52 -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=h2ZgkSOX; 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 0FFE83857349 for ; Sun, 30 Apr 2023 21:14:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0FFE83857349 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1682889284; bh=iypJl7fn714t+fSzdOPmISubYMZpVp/JLgKyGxmIfLE=; h=To:CC:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=h2ZgkSOXUoHANwcHigEWVmSmu9U+r9vE7Gc8yDCQLwtJZdE5AHBJur6LsfMQOQpMg P/0tjDp1mWRxgjGM3i1tRAhATciLNiMYZNsgLlijfkR2M3zj8dpHNkj26Xrkmolhzf 3ETF+j1zjt8Z00A6H8rg6xqN5/nBcMlASHI/AjQw= 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 EF3FC3858C1F for ; Sun, 30 Apr 2023 21:13:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EF3FC3858C1F 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 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) 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 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 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?1764637322533525227?= X-GMAIL-MSGID: =?utf-8?q?1764637322533525227?= 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);