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 DFE813889E24; Mon, 5 Dec 2022 06:30:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DFE813889E24 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 (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2B53lDlQ012211; Mon, 5 Dec 2022 06:30:27 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : references : date : in-reply-to : message-id : mime-version : content-type; s=pp1; bh=MGMdeslogPUFzaC4jdOsRJuxvNUOLBP0jhTomkFg/GQ=; b=V1aKGqeT6itWrmIouxxOOd81d2LB6B9y1Wm2qJrIy4ZFXddR3QPS5TCyuBpQ8iAAAyj7 rI6hUMTx4KyQcL7U84YfllGvvtrda9e7IUuB3zi4u8b2occz/LTaQ9ibJ58Hjhz9zEP2 8TbosFwmRmav/hYmpTlpDWFXfU9pKYku8ON6uEHXN1v7iLvdz8DtG78XuPeVe4E2QGn7 0u7SfmkkgQ4bvidT7657VSNNJx8rESCceNkS4G7PpJg2G/jHy4dv9RpSJYfNwL9hBQ+2 oQQQt1Cbh0F5smJbJ/DTk8L/Mu/1Yn0AYTmIEfte509FO8SFssJaNgpyEnAKWG6EF9Sz Cw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3m8ganhwfj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 05 Dec 2022 06:30:27 +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 2B52L9Yt039666; Mon, 5 Dec 2022 06:30:26 GMT Received: from ppma04wdc.us.ibm.com (1a.90.2fa9.ip4.static.sl-reverse.com [169.47.144.26]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3m8ganhwfc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 05 Dec 2022 06:30:26 +0000 Received: from pps.filterd (ppma04wdc.us.ibm.com [127.0.0.1]) by ppma04wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2B53LXB9029206; Mon, 5 Dec 2022 06:30:26 GMT Received: from smtprelay06.wdc07v.mail.ibm.com ([9.208.129.118]) by ppma04wdc.us.ibm.com with ESMTP id 3m7x39bsbj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 05 Dec 2022 06:30:26 +0000 Received: from smtpav02.wdc07v.mail.ibm.com (smtpav02.wdc07v.mail.ibm.com [10.39.53.229]) by smtprelay06.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2B56UOO351380574 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 5 Dec 2022 06:30:25 GMT Received: from smtpav02.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D41F658058; Mon, 5 Dec 2022 06:30:24 +0000 (GMT) Received: from smtpav02.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 653CD58060; Mon, 5 Dec 2022 06:30:24 +0000 (GMT) Received: from pike (unknown [9.5.12.127]) by smtpav02.wdc07v.mail.ibm.com (Postfix) with ESMTPS; Mon, 5 Dec 2022 06:30:24 +0000 (GMT) From: Jiufu Guo To: gcc-patches@gcc.gnu.org Cc: segher@kernel.crashing.org, dje.gcc@gmail.com, linkw@gcc.gnu.org, rguenther@suse.de, jeffreyalaw@gmail.com Subject: Re: [PATCH 1/3] Use sub mode to move block for struct parameter References: <20221129134507.185951-1-guojiufu@linux.ibm.com> Date: Mon, 05 Dec 2022 14:30:23 +0800 In-Reply-To: <20221129134507.185951-1-guojiufu@linux.ibm.com> (Jiufu Guo's message of "Tue, 29 Nov 2022 21:45:05 +0800") Message-ID: <7elenmuzuo.fsf@pike.rch.stglabs.ibm.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-GCONF: 00 X-Proofpoint-GUID: GPF43HobyhCg18Cewn3HE6IHQIZXp_K2 X-Proofpoint-ORIG-GUID: -IeXBP3hG1u-auKOBV8H81v7CehKeoC8 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-05_01,2022-12-01_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 lowpriorityscore=0 mlxscore=0 mlxlogscore=999 priorityscore=1501 suspectscore=0 clxscore=1015 adultscore=0 spamscore=0 phishscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2212050023 X-Spam-Status: No, score=-11.8 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 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, Jiufu Guo writes: > Hi, > > This patch checks an assignment to see if the "from" is about parameter, > and if the parameter may passing through registers, then use the register > mode to move sub-blocks for the assignment. > > Bootstraped and regtested on ppc{,le} and x86_64. > Is this ok for trunk? > > BR, > Jeff (Jiufu) > > gcc/ChangeLog: > > * expr.cc (move_sub_blocks): New function. > (expand_assignment): Call move_sub_blocks for assigning from parameter. > > --- > gcc/expr.cc | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 70 insertions(+) > > diff --git a/gcc/expr.cc b/gcc/expr.cc > index d9407432ea5..201fee6fd9a 100644 > --- a/gcc/expr.cc > +++ b/gcc/expr.cc > @@ -5559,6 +5559,57 @@ 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, bool nontemporal) > +{ > + HOST_WIDE_INT size, sub_size; > + int len; > + > + gcc_assert (MEM_P (to_rtx)); > + > + size = MEM_SIZE (to_rtx).to_constant (); > + sub_size = GET_MODE_SIZE (sub_mode).to_constant (); > + len = size / sub_size; > + > + /* As there are limit registers for passing parameters or return > + value according target ABI. It would be not profitable to move > + through sub-modes, if the size does not follow registers. */ > + int heurisitic_num = 8; > + if (!size || (size % sub_size) != 0 || len < 2 || len > heurisitic_num) > + { I think that when each parameter is initialized and handled during setup, we already figured out how it is passed by registers or stack (or mixed). And we could use this 'accurate' information and not need the arbitray number here. BR, Jeff (Jiufu) > + push_temp_slots (); > + rtx result = store_expr (from, to_rtx, 0, nontemporal, false); > + preserve_temp_slots (result); > + pop_temp_slots (); > + return; > + } > + > + push_temp_slots (); > + > + rtx from_rtx; > + from_rtx = expand_expr (from, NULL_RTX, GET_MODE (to_rtx), EXPAND_NORMAL); > + for (int i = 0; i < len; i++) > + { > + rtx temp = gen_reg_rtx (sub_mode); > + rtx src = adjust_address (from_rtx, sub_mode, sub_size * i); > + rtx dest = adjust_address (to_rtx, sub_mode, sub_size * i); > + emit_move_insn (temp, src); > + emit_move_insn (dest, temp); > + } > + > + preserve_temp_slots (to_rtx); > + pop_temp_slots (); > + return; > +} > + > /* Expand an assignment that stores the value of FROM into TO. If NONTEMPORAL > is true, try generating a nontemporal store. */ > > @@ -6045,6 +6096,25 @@ expand_assignment (tree to, tree from, bool nontemporal) > return; > } > > + /* If it is assigning from a struct param which may be passed via registers, > + It would be better to use the register's mode to move sub-blocks for the > + assignment. */ > + if (TREE_CODE (from) == PARM_DECL && mode == BLKmode > + && DECL_INCOMING_RTL (from) > + && (GET_CODE (DECL_INCOMING_RTL (from)) == PARALLEL > + || REG_P (DECL_INCOMING_RTL (from)))) > + { > + rtx parm = DECL_INCOMING_RTL (from); > + machine_mode sub_mode; > + if (REG_P (parm)) > + sub_mode = word_mode; > + else > + sub_mode = GET_MODE (XEXP (XVECEXP (parm, 0, 0), 0)); > + > + move_sub_blocks (to_rtx, from, sub_mode, nontemporal); > + return; > + } > + > /* Compute FROM and store the value in the rtx we got. */ > > push_temp_slots ();