From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id D6BF23858D28; Thu, 4 May 2023 05:49:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D6BF23858D28 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 Received: from pps.filterd (m0353723.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3445WHSU030008; Thu, 4 May 2023 05:49:42 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=date : from : to : cc : subject : in-reply-to : references : message-id : content-type : content-transfer-encoding : mime-version; s=pp1; bh=kOly5B7Xd3FWrNieR65hvOR7/4iOfpOGrUHcYTx+NYI=; b=UuERtZWn920DbfTJz5XSPR6EXgnd0ctJV8aNf9CHCuKWvO0CUbOoDeMZxY2fZgL1cCtt vqYxU9BrveRXnFPF8qKeRFzkBT7WmJ8rCq9P/ipjkp/tbk4UOcTt1adjoGM7EqrfbhrL serBMB4jV99s9BRnP6GiFUSfsvrVXpdzb7vtmb0tyf0w0+LeZIeKPI7ynbtl1Jwg3yPh vxypXV/aSYYrqv/skkajnNxLLUrDG7hykYjRENJUQHBqBh8T3zfHmJd9YzisCXLSreRO UqKJolZWyDblXh0TPwTV9pCERLsQZDK1xPovyNHL3GerxrnNQDuWRhjiXs3jHGA1nUPi 6w== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3qc66u1607-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 May 2023 05:49:42 +0000 Received: from m0353723.ppops.net (m0353723.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3445nfjt028991; Thu, 4 May 2023 05:49:41 GMT Received: from ppma02wdc.us.ibm.com (aa.5b.37a9.ip4.static.sl-reverse.com [169.55.91.170]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3qc66u15yt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 May 2023 05:49:41 +0000 Received: from pps.filterd (ppma02wdc.us.ibm.com [127.0.0.1]) by ppma02wdc.us.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 34440RWr004345; Thu, 4 May 2023 05:49:41 GMT Received: from smtprelay06.wdc07v.mail.ibm.com ([9.208.129.118]) by ppma02wdc.us.ibm.com (PPS) with ESMTPS id 3q8tv8g2nc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 May 2023 05:49:41 +0000 Received: from smtpav05.wdc07v.mail.ibm.com (smtpav05.wdc07v.mail.ibm.com [10.39.53.232]) by smtprelay06.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3445ndO149873370 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 4 May 2023 05:49:40 GMT Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D901158053; Thu, 4 May 2023 05:49:39 +0000 (GMT) Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1F1A658043; Thu, 4 May 2023 05:49:39 +0000 (GMT) Received: from ltc.linux.ibm.com (unknown [9.5.196.140]) by smtpav05.wdc07v.mail.ibm.com (Postfix) with ESMTP; Thu, 4 May 2023 05:49:39 +0000 (GMT) Date: Thu, 04 May 2023 13:49:38 +0800 From: guojiufu To: Jeff Law Cc: gcc-patches@gcc.gnu.org, rguenther@suse.de, segher@kernel.crashing.org, dje.gcc@gmail.com, linkw@gcc.gnu.org, meissner@linux.ibm.com Subject: Re: [PATCH V5] Use reg mode to move sub blocks for parameters and returns In-Reply-To: <0221bead-5d08-cb56-e620-642825c1abc3@gmail.com> References: <20230317033952.1549050-1-guojiufu@linux.ibm.com> <0221bead-5d08-cb56-e620-642825c1abc3@gmail.com> Message-ID: X-Sender: guojiufu@linux.ibm.com Content-Type: text/plain; charset=US-ASCII; format=flowed X-TM-AS-GCONF: 00 X-Proofpoint-GUID: UKoJOUWJzAX5mULhnPUfFSIASlkZLm9U X-Proofpoint-ORIG-GUID: KhOeQeT7GsrW1dZeaDqam7xrUKRDgOsu Content-Transfer-Encoding: 7bit X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 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-05-04_02,2023-05-03_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxscore=0 phishscore=0 suspectscore=0 bulkscore=0 malwarescore=0 spamscore=0 impostorscore=0 lowpriorityscore=0 adultscore=0 clxscore=1011 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2305040046 X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,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 List-Id: Hi, On 2023-05-01 03:00, Jeff Law wrote: > On 3/16/23 21:39, Jiufu Guo wrote: >> Hi, >> >> When assigning a parameter to a variable, or assigning a variable to >> return value with struct type, and the parameter/return is passed >> through registers. >> For this kind of case, it would be better to use the nature mode of >> the registers to move the content for the assignment. >> >> As the example code (like code in PR65421): >> >> typedef struct SA {double a[3];} A; >> A ret_arg_pt (A *a) {return *a;} // on ppc64le, expect only 3 lfd(s) >> A ret_arg (A a) {return a;} // just empty fun body >> void st_arg (A a, A *p) {*p = a;} //only 3 stfd(s) >> >> Comparing with previous version: >> https://gcc.gnu.org/pipermail/gcc-patches/2023-January/609394.html >> This version refine code to eliminated reductant code in the sub >> routine "move_sub_blocks". >> >> Bootstrap and regtest pass on ppc64{,le}. >> Is this ok for trunk? >> ... >> diff --git a/gcc/expr.cc b/gcc/expr.cc >> index 15be1c8db99..97a7be9542e 100644 >> --- a/gcc/expr.cc >> +++ b/gcc/expr.cc >> @@ -5559,6 +5559,41 @@ mem_ref_refers_to_non_mem_p (tree ref) >> return non_mem_decl_p (base); >> } >> +/* Sub routine of expand_assignment, invoked when assigning from a >> + parameter or assigning to a return val on struct type which may >> + be passed through registers. The mode of register is used to >> + move the content for the assignment. >> + >> + This routine generates code for expression FROM which is BLKmode, >> + and move the generated content to TO_RTX by su-blocks in SUB_MODE. >> */ >> + >> +static void >> +move_sub_blocks (rtx to_rtx, tree from, machine_mode sub_mode) >> +{ >> + gcc_assert (MEM_P (to_rtx)); >> + >> + HOST_WIDE_INT size = MEM_SIZE (to_rtx).to_constant (); > Consider the case of a BLKmode return value. Isn't TO_RTX in this > case a BLKmode object? Thanks for this question! Yes, the mode of TO_RTX is BLKmode. As we know, when the function returns via registers, the mode of the `return-rtx` could also be BLKmode. This patch is going to improve these kinds of cases. For example: ``` typedef struct FLOATS { double a[3]; } FLOATS; FLOATS ret_arg_pt (FLOATS *a){return *a;} ``` D.3952 = *a_2(D); //this patch enhance this assignment return D.3952; The mode is BLKmode for the rtx of `D.3952` is BLKmode, and the rtx for "DECL_RESULT(current_function_decl)". And the DECL_RESULT represents the return registers. BR, Jeff (Jiufu) > > It looks pretty good at this point. > > jeff