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 BAE19383303A for ; Wed, 23 Jun 2021 22:19:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BAE19383303A Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 15NMGZS8006605 for ; Wed, 23 Jun 2021 15:19:21 -0700 Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com with ESMTP id 39bx5jbxje-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Wed, 23 Jun 2021 15:19:20 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Wed, 23 Jun 2021 15:19:19 -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.18 via Frontend Transport; Wed, 23 Jun 2021 15:19:19 -0700 Received: from linux.wrightpinski.org.com (unknown [10.69.242.197]) by maili.marvell.com (Postfix) with ESMTP id 364755B694F; Wed, 23 Jun 2021 15:19:19 -0700 (PDT) From: To: CC: Andrew Pinski Subject: [PATCH 3/7] Duplicate the range information of the phi onto the new ssa_name Date: Wed, 23 Jun 2021 15:19:11 -0700 Message-ID: <1624486755-12879-4-git-send-email-apinski@marvell.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1624486755-12879-1-git-send-email-apinski@marvell.com> References: <1624486755-12879-1-git-send-email-apinski@marvell.com> MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-ORIG-GUID: SwvjQ4pQ0-ugt6_F_2EjSh6fbKXf_w7W X-Proofpoint-GUID: SwvjQ4pQ0-ugt6_F_2EjSh6fbKXf_w7W X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.790 definitions=2021-06-23_14:2021-06-23, 2021-06-23 signatures=0 X-Spam-Status: No, score=-14.4 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.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-List-Received-Date: Wed, 23 Jun 2021 22:19:23 -0000 From: Andrew Pinski Since match_simplify_replacement uses gimple_simplify, there is a new ssa name created sometimes and then we go and replace the phi edge with this new ssa name, the range information on the phi is lost. Placing this in replace_phi_edge_with_variable is the best option instead of doing it in each time replace_phi_edge_with_variable is called which is what is done today. OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. gcc/ChangeLog: * tree-ssa-phiopt.c (replace_phi_edge_with_variable): Duplicate range info if we're the only things setting the target PHI. (value_replacement): Don't duplicate range here. (minmax_replacement): Likewise. --- gcc/tree-ssa-phiopt.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c index 24cbce9955a..147397ad82c 100644 --- a/gcc/tree-ssa-phiopt.c +++ b/gcc/tree-ssa-phiopt.c @@ -391,6 +391,24 @@ replace_phi_edge_with_variable (basic_block cond_block, basic_block bb = gimple_bb (phi); basic_block block_to_remove; gimple_stmt_iterator gsi; + tree phi_result = PHI_RESULT (phi); + + /* Duplicate range info as needed. */ + if (TREE_CODE (new_tree) == SSA_NAME + && EDGE_COUNT (gimple_bb (phi)->preds) == 2 + && INTEGRAL_TYPE_P (TREE_TYPE (phi_result))) + { + if (!SSA_NAME_RANGE_INFO (new_tree) + && SSA_NAME_RANGE_INFO (phi_result)) + duplicate_ssa_name_range_info (new_tree, + SSA_NAME_RANGE_TYPE (phi_result), + SSA_NAME_RANGE_INFO (phi_result)); + if (SSA_NAME_RANGE_INFO (new_tree) + && !SSA_NAME_RANGE_INFO (phi_result)) + duplicate_ssa_name_range_info (phi_result, + SSA_NAME_RANGE_TYPE (new_tree), + SSA_NAME_RANGE_INFO (new_tree)); + } /* Change the PHI argument to new. */ SET_USE (PHI_ARG_DEF_PTR (phi, e->dest_idx), new_tree); @@ -1385,16 +1403,6 @@ value_replacement (basic_block cond_bb, basic_block middle_bb, : # u_3 = PHI */ reset_flow_sensitive_info (lhs); - if (INTEGRAL_TYPE_P (TREE_TYPE (lhs))) - { - /* If available, we can use VR of phi result at least. */ - tree phires = gimple_phi_result (phi); - struct range_info_def *phires_range_info - = SSA_NAME_RANGE_INFO (phires); - if (phires_range_info) - duplicate_ssa_name_range_info (lhs, SSA_NAME_RANGE_TYPE (phires), - phires_range_info); - } gimple_stmt_iterator gsi_from; for (int i = prep_cnt - 1; i >= 0; --i) { @@ -1794,13 +1802,6 @@ minmax_replacement (basic_block cond_bb, basic_block middle_bb, gimple_seq stmts = NULL; tree phi_result = PHI_RESULT (phi); result = gimple_build (&stmts, minmax, TREE_TYPE (phi_result), arg0, arg1); - /* Duplicate range info if we're the only things setting the target PHI. */ - if (!gimple_seq_empty_p (stmts) - && EDGE_COUNT (gimple_bb (phi)->preds) == 2 - && !POINTER_TYPE_P (TREE_TYPE (phi_result)) - && SSA_NAME_RANGE_INFO (phi_result)) - duplicate_ssa_name_range_info (result, SSA_NAME_RANGE_TYPE (phi_result), - SSA_NAME_RANGE_INFO (phi_result)); gsi = gsi_last_bb (cond_bb); gsi_insert_seq_before (&gsi, stmts, GSI_NEW_STMT); -- 2.27.0