From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx07-00178001.pphosted.com (mx07-00178001.pphosted.com [185.132.182.106]) by sourceware.org (Postfix) with ESMTPS id CC26F3858C2C for ; Thu, 30 Sep 2021 13:51:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CC26F3858C2C Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 18UDbEWx003138 for ; Thu, 30 Sep 2021 15:51:09 +0200 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 3bdaa6srcx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 30 Sep 2021 15:51:09 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 2081910002A for ; Thu, 30 Sep 2021 15:51:07 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag2node2.st.com [10.75.127.5]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 7BD9224DF6B for ; Thu, 30 Sep 2021 15:51:07 +0200 (CEST) Received: from [10.211.14.1] (10.75.127.47) by SFHDAG2NODE2.st.com (10.75.127.5) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Thu, 30 Sep 2021 15:51:07 +0200 Message-ID: <94aad3b0-7455-931e-2484-adcf2fcc1051@foss.st.com> Date: Thu, 30 Sep 2021 15:51:06 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.1.2 Subject: Re: [PATCH] aarch64: Improve size heuristic for cpymem expansion Content-Language: en-US To: References: From: Christophe LYON In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.75.127.47] X-ClientProxiedBy: SFHDAG1NODE3.st.com (10.75.127.3) To SFHDAG2NODE2.st.com (10.75.127.5) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.391,FMLib:17.0.607.475 definitions=2021-09-30_04,2021-09-30_01,2020-04-07_01 X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, KAM_SHORT, NICE_REPLY_A, RCVD_IN_DNSWL_LOW, SCC_5_SHORT_WORD_LINES, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Thu, 30 Sep 2021 13:51:13 -0000 On 29/09/2021 12:20, Kyrylo Tkachov via Gcc-patches wrote: > Hi all, > > Similar to my previous patch for setmem this one does the same for the cpymem expansion. > We count the number of ops emitted and compare it against the alternative of just calling > the library function when optimising for size. > For the code: > void > cpy_127 (char *out, char *in) > { > __builtin_memcpy (out, in, 127); > } > > void > cpy_128 (char *out, char *in) > { > __builtin_memcpy (out, in, 128); > } > > we now emit a call to memcpy (with an extra MOV-immediate instruction for the size) instead of: > cpy_127(char*, char*): > ldp q0, q1, [x1] > stp q0, q1, [x0] > ldp q0, q1, [x1, 32] > stp q0, q1, [x0, 32] > ldp q0, q1, [x1, 64] > stp q0, q1, [x0, 64] > ldr q0, [x1, 96] > str q0, [x0, 96] > ldr q0, [x1, 111] > str q0, [x0, 111] > ret > cpy_128(char*, char*): > ldp q0, q1, [x1] > stp q0, q1, [x0] > ldp q0, q1, [x1, 32] > stp q0, q1, [x0, 32] > ldp q0, q1, [x1, 64] > stp q0, q1, [x0, 64] > ldp q0, q1, [x1, 96] > stp q0, q1, [x0, 96] > ret > > which is a clear code size win. Speed optimisation heuristics remain unchanged. > Bootstrapped and tested on aarch64-none-linux-gnu. > Pushing to trunk. > > Thanks, > Kyrill > > 2021-09-29 Kyrylo Tkachov > > * config/aarch64/aarch64.c (aarch64_expand_cpymem): Count number of > emitted operations and adjust heuristic for code size. > > 2021-09-29 Kyrylo Tkachov > > * gcc.target/aarch64/cpymem-size.c: New test. Hi Kyrill, Just to mention that the new test fails with -mabi=ilp32... Thanks, Christophe