From patchwork Wed Apr 19 17:56:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajit Agarwal X-Patchwork-Id: 1770858 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=OuJzQqMO; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Q1pQV5xLwz23tD for ; Thu, 20 Apr 2023 03:57:06 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2E6E13857BB2 for ; Wed, 19 Apr 2023 17:57:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2E6E13857BB2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1681927023; bh=Yy/PdF6pEGdhm2XYJ9h/LocFDZuCsCaZYVkoc/WU1J8=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=OuJzQqMOmh6b8pT6rMthA6pSlhFXafdSHiNW4uZon5RpJpMtL1gKWgMFVKvTQHRjE lDkqNiK5FA3wX5gJ8EsGN+Ezk1e7TR2HPdqS9blazbvm0IoYhfpiMC6Pd9/GXcFGxv drM2zoUwkMunQfbzyHVb7eQKBCBb07aoDilaXjzc= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id C98CB3858418 for ; Wed, 19 Apr 2023 17:56:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C98CB3858418 Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 33JGiuu6030784; Wed, 19 Apr 2023 17:56:42 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3q28u087fj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 19 Apr 2023 17:56:41 +0000 Received: from m0127361.ppops.net (m0127361.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 33JHUS6I040560; Wed, 19 Apr 2023 17:56:41 GMT Received: from ppma01dal.us.ibm.com (83.d6.3fa9.ip4.static.sl-reverse.com [169.63.214.131]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3q28u087f5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 19 Apr 2023 17:56:41 +0000 Received: from pps.filterd (ppma01dal.us.ibm.com [127.0.0.1]) by ppma01dal.us.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 33JG0xnt003686; Wed, 19 Apr 2023 17:56:40 GMT Received: from smtprelay06.wdc07v.mail.ibm.com ([9.208.129.118]) by ppma01dal.us.ibm.com (PPS) with ESMTPS id 3pykj85pcg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 19 Apr 2023 17:56:40 +0000 Received: from smtpav06.wdc07v.mail.ibm.com (smtpav06.wdc07v.mail.ibm.com [10.39.53.233]) by smtprelay06.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 33JHuci87930568 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 19 Apr 2023 17:56:38 GMT Received: from smtpav06.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BA04B58054; Wed, 19 Apr 2023 17:56:38 +0000 (GMT) Received: from smtpav06.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0C5865803F; Wed, 19 Apr 2023 17:56:36 +0000 (GMT) Received: from [9.43.84.11] (unknown [9.43.84.11]) by smtpav06.wdc07v.mail.ibm.com (Postfix) with ESMTP; Wed, 19 Apr 2023 17:56:35 +0000 (GMT) Message-ID: Date: Wed, 19 Apr 2023 23:26:34 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Content-Language: en-US To: gcc-patches Cc: Jeff Law , Segher Boessenkool , Peter Bergner , Jakub Jelinek , Richard Biener Subject: [PATCH v3 2/4] ree : Code movement to avoid adding prototype to improve ree pass for rs6000 target. X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 84k-Kg6hAdqAVDmMkBI5XrkRQpqlM2PY X-Proofpoint-GUID: r1vbeaUa-7npfOBHdXE0wEVUquR80c1N 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-19_11,2023-04-18_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 impostorscore=0 bulkscore=0 lowpriorityscore=0 phishscore=0 adultscore=0 mlxlogscore=999 clxscore=1015 priorityscore=1501 mlxscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304190153 X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, 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: Ajit Agarwal via Gcc-patches From: Ajit Agarwal Reply-To: Ajit Agarwal Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Hello All: This is the patch-2 to improve ree pass for rs6000 target. Bootstrapped and regtested on powerpc64-gnu-linux. Thanks & Regards Ajit ree: Improve ree pass for rs6000 target. For rs6000 target we see redundant zero and sign extension and done to improve ree pass to eliminate such redundant zero and sign extension. 2023-04-19 Ajit Kumar Agarwal gcc/ChangeLog: * ree.cc (get_defs): Move function to avoid prototype. --- gcc/ree.cc | 94 +++++++++++++++++++++++++++--------------------------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/gcc/ree.cc b/gcc/ree.cc index 413aec7c8eb..93d300a9e96 100644 --- a/gcc/ree.cc +++ b/gcc/ree.cc @@ -253,6 +253,53 @@ struct ext_cand static int max_insn_uid; +/* Get all the reaching definitions of an instruction. The definitions are + desired for REG used in INSN. Return the definition list or NULL if a + definition is missing. If DEST is non-NULL, additionally push the INSN + of the definitions onto DEST. */ + +static struct df_link * +get_defs (rtx_insn *insn, rtx reg, vec *dest) +{ + df_ref use; + struct df_link *ref_chain, *ref_link; + + FOR_EACH_INSN_USE (use, insn) + { + if (GET_CODE (DF_REF_REG (use)) == SUBREG) + return NULL; + if (REGNO (DF_REF_REG (use)) == REGNO (reg)) + break; + } + + if (use == NULL) + return NULL; + + ref_chain = DF_REF_CHAIN (use); + + for (ref_link = ref_chain; ref_link; ref_link = ref_link->next) + { + /* Problem getting some definition for this instruction. */ + if (ref_link->ref == NULL) + return NULL; + if (DF_REF_INSN_INFO (ref_link->ref) == NULL) + return NULL; + /* As global regs are assumed to be defined at each function call + dataflow can report a call_insn as being a definition of REG. + But we can't do anything with that in this pass so proceed only + if the instruction really sets REG in a way that can be deduced + from the RTL structure. */ + if (global_regs[REGNO (reg)] + && !set_of (reg, DF_REF_INSN (ref_link->ref))) + return NULL; + } + + if (dest) + for (ref_link = ref_chain; ref_link; ref_link = ref_link->next) + dest->safe_push (DF_REF_INSN (ref_link->ref)); + + return ref_chain; +} /* Update or remove REG_EQUAL or REG_EQUIV notes for INSN. */ static bool @@ -454,53 +501,6 @@ transform_ifelse (ext_cand *cand, rtx_insn *def_insn) return false; } -/* Get all the reaching definitions of an instruction. The definitions are - desired for REG used in INSN. Return the definition list or NULL if a - definition is missing. If DEST is non-NULL, additionally push the INSN - of the definitions onto DEST. */ - -static struct df_link * -get_defs (rtx_insn *insn, rtx reg, vec *dest) -{ - df_ref use; - struct df_link *ref_chain, *ref_link; - - FOR_EACH_INSN_USE (use, insn) - { - if (GET_CODE (DF_REF_REG (use)) == SUBREG) - return NULL; - if (REGNO (DF_REF_REG (use)) == REGNO (reg)) - break; - } - - gcc_assert (use != NULL); - - ref_chain = DF_REF_CHAIN (use); - - for (ref_link = ref_chain; ref_link; ref_link = ref_link->next) - { - /* Problem getting some definition for this instruction. */ - if (ref_link->ref == NULL) - return NULL; - if (DF_REF_INSN_INFO (ref_link->ref) == NULL) - return NULL; - /* As global regs are assumed to be defined at each function call - dataflow can report a call_insn as being a definition of REG. - But we can't do anything with that in this pass so proceed only - if the instruction really sets REG in a way that can be deduced - from the RTL structure. */ - if (global_regs[REGNO (reg)] - && !set_of (reg, DF_REF_INSN (ref_link->ref))) - return NULL; - } - - if (dest) - for (ref_link = ref_chain; ref_link; ref_link = ref_link->next) - dest->safe_push (DF_REF_INSN (ref_link->ref)); - - return ref_chain; -} - /* Get all the reaching uses of an instruction. The uses are desired for REG set in INSN. Return use list or NULL if a use is missing or irregular. */