From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id 6307A3858D37 for ; Mon, 23 Oct 2023 06:46:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6307A3858D37 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6307A3858D37 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698043598; cv=none; b=I4F0+hHPqXl1+RkpHZi1Mbshp11Io4PbANsvb+0KitgDcA6xTDqQjmGOc/uFEk1eb8H+ylueEADQFtWz3uSolHPyCAzgZ1tVjsbFx/mzIJF8AWs9wZ8ggzzlevFFENj/DxX1tK4x+oVWfOLnHo1OaP+ZpxxI+vbyZvXql8XqbBE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698043598; c=relaxed/simple; bh=qsXoMFiAdQVoWUaLauUkLD4MwEYcPJQbRVpjyT0Ir+g=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=Xvl6SntOmx4bGv5xKhjYTvZPu98oF6AA2YSNWfT5Mis6QprV0NkgQr4J1MC/WzBkohfvR2dkm1tKg01F7K0Q6rC+bBnDNwJmrBQOJQe9YSvT15fLK+mwJRkLv2xDKE/rdxw8M0fRLwKGYtKs9PnS0RE5Zs5R7PmU2QzvLs49IMM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 39N6GKKF031337; Mon, 23 Oct 2023 06:46:34 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=pp1; bh=ZR1cfrL2YkqM4G56kgX+/cpxxNcab+BXTm8po4nw8zY=; b=bSRjhi/yj/R+G/TwAuKU0cxeuIWN7hFf6wmKhdk7g0VoZYNfrHCAtPy9yMDCXrNgpYBU 4F+lJwzszKJvRFUziZUBkF5apUmDVS7tPz0VvKiM5+I/ciMaD/+1ZW1VxBa1RtZ+LlOs 9mE4AnSCl9mMHy8HwWWMwtSFsPPsTYRm80qE4BmJBjhbMqK1nRLUJRNADwvKI+bpmnDW pA9VURbZucrbq1wt3aW1fxSOcsnttrL4C90+pb7vblzxZThXHP63SoxzJwm/fokw9Fpg DCGHI+KhghvWZXIgBieSM34nT3WQ0uAD8JS+hbG8qxm/voaKajf5fQRlmEtErZbA8Gy4 uw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3twhp1jsxf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 23 Oct 2023 06:46:34 +0000 Received: from m0356517.ppops.net (m0356517.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 39N6GcuK001560; Mon, 23 Oct 2023 06:46:33 GMT Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3twhp1jsun-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 23 Oct 2023 06:46:32 +0000 Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 39N5eUPH012387; Mon, 23 Oct 2023 06:46:24 GMT Received: from smtprelay03.dal12v.mail.ibm.com ([172.16.1.5]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3tvup1ef9v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 23 Oct 2023 06:46:24 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay03.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 39N6kNT22163272 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 23 Oct 2023 06:46:23 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9883D58061; Mon, 23 Oct 2023 06:46:23 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2B71858059; Mon, 23 Oct 2023 06:46:20 +0000 (GMT) Received: from [9.43.84.41] (unknown [9.43.84.41]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Mon, 23 Oct 2023 06:46:19 +0000 (GMT) Message-ID: Date: Mon, 23 Oct 2023 12:16:18 +0530 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v9 4/4] ree: Improve ree pass for rs6000 target using defined ABI interfaces Content-Language: en-US To: rep.dot.nop@gmail.com, gcc-patches@gcc.gnu.org, Vineet Gupta Cc: Jeff Law , Richard Biener , Segher Boessenkool , Peter Bergner , gnu-toolchain References: <32ca6e0e-ef68-4d4d-b864-c586a688b2c7@linux.ibm.com> <22541c92-a967-4e66-96b3-e4ad5011cd24@rivosinc.com> From: Ajit Agarwal In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: i87VvXetcvsbSzSggN_lCitzgCtB4VoW X-Proofpoint-GUID: ZFod2KqbhNMzPT08pVrFZAmNW3wyoQv7 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-23_04,2023-10-19_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 adultscore=0 priorityscore=1501 mlxscore=0 mlxlogscore=999 clxscore=1015 phishscore=0 malwarescore=0 bulkscore=0 impostorscore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310170001 definitions=main-2310230059 X-Spam-Status: No, score=-6.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,GB_TO_NAME_FREEMAIL,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,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: Hello All: Addressed below review comments in the version 11 of the patch. Please review and please let me know if its ok for trunk. Thanks & Regards Ajit On 22/10/23 12:56 am, rep.dot.nop@gmail.com wrote: > On 21 October 2023 01:56:16 CEST, Vineet Gupta wrote: >> On 10/19/23 23:50, Ajit Agarwal wrote: >>> Hello All: >>> >>> This version 9 of the patch uses abi interfaces to remove zero and sign extension elimination. >>> Bootstrapped and regtested on powerpc-linux-gnu. >>> >>> In this version (version 9) of the patch following review comments are incorporated. >>> >>> a) Removal of hard code zero_extend and sign_extend in abi interfaces. >>> b) Source and destination with different registers are considered. >>> c) Further enhancements. >>> d) Added sign extension elimination using abi interfaces. >> >> As has been trend in the past, I don't think all the review comments have been addressed. > > And apart from that, may I ask if this is just me, or does anybody else think that it might be worthwhile to actually read a patch before (re-)posting? > > Seeing e.g. the proposed abi_extension_candidate_p as written in a first POC would deserve some manual CSE, if nothing more then for clarity and conciseness? > > Just curious from a meta perspective.. > > And: > >>> ree: Improve ree pass for rs6000 target using defined abi interfaces > > mentioning powerpc like this, and then changing generic code could be interpreted as misleading, IMHO. > >>> >>> For rs6000 target we see redundant zero and sign extension and done >>> to improve ree pass to eliminate such redundant zero and sign extension >>> using defined ABI interfaces. > > Mentioning powerpc in the body as one of the affected target(s) is of course fine. > > >>> +/* Return TRUE if target mode is equal to source mode of zero_extend >>> + or sign_extend otherwise false. */ > > , false otherwise. > > But I'm not a native speaker > > >>> +/* Return TRUE if the candidate insn is zero extend and regno is >>> + a return registers. */ >>> + >>> +static bool >>> +abi_extension_candidate_return_reg_p (/*rtx_insn *insn, */int regno) > > Leftover debug comment. > >>> +{ >>> + if (targetm.calls.function_value_regno_p (regno)) >>> + return true; >>> + >>> + return false; >>> +} >>> + > > As said, I don't see why the below was not cleaned up before the V1 submission. > Iff it breaks when manually CSEing, I'm curious why? > >>> +/* Return TRUE if reg source operand of zero_extend is argument registers >>> + and not return registers and source and destination operand are same >>> + and mode of source and destination operand are not same. */ >>> + >>> +static bool >>> +abi_extension_candidate_p (rtx_insn *insn) >>> +{ >>> + rtx set = single_set (insn); >>> + machine_mode dst_mode = GET_MODE (SET_DEST (set)); >>> + rtx orig_src = XEXP (SET_SRC (set), 0); >>> + >>> + if (!FUNCTION_ARG_REGNO_P (REGNO (orig_src)) >>> + || abi_extension_candidate_return_reg_p (/*insn,*/ REGNO (orig_src))) > > On top, debug leftover. > >>> + return false; >>> + >>> + /* Mode of destination and source should be different. */ >>> + if (dst_mode == GET_MODE (orig_src)) >>> + return false; >>> + >>> + machine_mode mode = GET_MODE (XEXP (SET_SRC (set), 0)); >>> + bool promote_p = abi_target_promote_function_mode (mode); >>> + >>> + /* REGNO of source and destination should be same if not >>> + promoted. */ >>> + if (!promote_p && REGNO (SET_DEST (set)) != REGNO (orig_src)) >>> + return false; >>> + >>> + return true; >>> +} >>> + > > As said, please also rephrase the above (and everything else if it obviously looks akin the above). > > The rest, mentioned below, should largely be covered by following the coding convention. > >>> +/* Return TRUE if the candidate insn is zero extend and regno is >>> + an argument registers. */ > > Singular register. > >>> + >>> +static bool >>> +abi_extension_candidate_argno_p (/*rtx_code code, */int regno) > > Debug leftover. > I would probably have inlined this function manually, with a respective comment. > Did not look how often it is used, admittedly. > >>> +{ >>> + if (FUNCTION_ARG_REGNO_P (regno)) >>> + return true; >>> + >>> + return false; >>> +} > [] >>> + >>> /* This function goes through all reaching defs of the source > > s/This function goes/Go/ > >>> of the candidate for elimination (CAND) and tries to combine > > (of, ?didn't look) candidate CAND for eliminating > >>> the extension with the definition instruction. The changes > > defining > > Pre-existing, I know. > But you could fix those in a preparatory patch while you touch surrounding code. > This is not a requirement, of course, just good habit, IMHO. > >>> @@ -770,6 +889,11 @@ combine_reaching_defs (ext_cand *cand, const_rtx set_pat, ext_state *state) >>> state->defs_list.truncate (0); >>> state->copies_list.truncate (0); >>> + rtx orig_src = XEXP (SET_SRC (cand->expr),0); >>> + >>> + if (abi_extension_candidate_p (cand->insn) >>> + && (!get_defs (cand->insn, orig_src, NULL))) > > Excess braces. > Hopefully check_gnu_style would have complained. > >>> + return abi_handle_regs (cand->insn); >>> outcome = make_defs_and_copies_lists (cand->insn, set_pat, state); >>> @@ -1036,6 +1160,15 @@ combine_reaching_defs (ext_cand *cand, const_rtx set_pat, ext_state *state) >>> } >>> } >>> + rtx insn_set = single_set (cand->insn); >>> + >>> + machine_mode mode = (GET_MODE (XEXP (SET_SRC (insn_set), 0))); > > Excess braces. > Also in a lot of other spots in your patch. > Please read the coding conventions and the patch, once again, before submission? > thanks