| Message ID | 09b3c02087c1bdaa27c9caa103be363cd2ce2af4.camel@espressif.com |
|---|---|
| State | New |
| Headers |
Return-Path: <newlib-bounces~patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 28E153857820 for <patchwork@sourceware.org>; Mon, 25 Aug 2025 12:20:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 28E153857820 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=espressifsystems.onmicrosoft.com header.i=@espressifsystems.onmicrosoft.com header.a=rsa-sha256 header.s=selector1-espressifsystems-onmicrosoft-com header.b=u8HO/VNe X-Original-To: newlib@sourceware.org Delivered-To: newlib@sourceware.org Received: from TYDPR03CU002.outbound.protection.outlook.com (mail-japaneastazon11023128.outbound.protection.outlook.com [52.101.127.128]) by sourceware.org (Postfix) with ESMTPS id 0781C3858D29 for <newlib@sourceware.org>; Mon, 25 Aug 2025 12:20:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0781C3858D29 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=espressif.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=espressif.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0781C3858D29 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=52.101.127.128 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1756124408; cv=pass; b=e4/9JyB310EJk1lKG2CeQMEPPmwwBvPQsW3UvhY21rp4owcICtw32wkJ2vffooP90G8txU9zsGmkT5xJDSNoDfUs0cKngP7ebvxh32Wz81Makh4lGa7aO5EUbVkD+iyW2s9/EZQt119XbyjDYApm6u7IMbNb3NDS4x6qsOQcuBg= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1756124408; c=relaxed/simple; bh=V4YMvvXX/RK1MBaA8c1QmaZ0tah/LVEUR7KGBeELGkI=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=T4zuaE6hGUI++qIRsXmsiVu+1r2gsWtjPkF/u4GtN2TaIVPQBy0IuYUU0QtkNKPce637hHINvLgcgQpW3DdyZyjXGlOk9gGqu8pVXJOQ03dkHHgUjUQsvpF2Qh/J6+/LTdsdDZgve8onJw7Y6qL/cQjpoI4vhlr37gXNd1D3yAE= ARC-Authentication-Results: i=2; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0781C3858D29 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=OcuxGRPcqjf48EGEdygAouKdiD53XwjQCPY5W2rjL3GivEWw0X6YNKKsUxIA/SG+1T4gsiePYW5MV9FojsrQhU3M1fjqj++jxTzwEd3B52pgG0u9DU5WkgmWakGZLdPlB6l2ckimIVvP3d90xn8+unaWbF942rvBeO46JgCAUB6l8tKQ3SfNDCVnlqTFy2Yn0LsQAEYKwiymiXgHOajy2Qb1KRUl3Tz9NhF03DmVEz58CsRfJNoXcJBCczhn9Tz9A/Ha4+uxOA4NQKeERd3XylcuafTzk9jiMeLmCdTAxHWiqNNxFy84XduXYnKQj8F/Xfm5rAhRvXbJl3Hiz/nIIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=V4YMvvXX/RK1MBaA8c1QmaZ0tah/LVEUR7KGBeELGkI=; b=DLDsfHsL8qkuqaxFzsZR1LQ0+lhs52vOR4fgb0HfcWYATA6RP+9dpOK0SDAG5933ME4OuQP/qqvf8pOjaoLLxtEHkYWHLPSR6GwPrNxh5a/x6fDsFLS/9xdhhV2/d2DRfxJyK73V1xQL3Rnt0SGIKYZz/6UtSRRQJ6vfaY8yf1q80/mEnoLEdSkfKlFxcse7N7Kv+L3F4gOLRUlOQSCG1aggb0z7khGoRMmXUD3TXqOdEESFbsZdpkGjYYdvDm12BPhemMZZ8qQvd2skhCIa2oXhLIc76ptpEPWqvC8KoOVhHDl129VLQEOFrGhLAf32Rqtk8AImBm+E1PmCg5OgYw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=espressif.com; dmarc=pass action=none header.from=espressif.com; dkim=pass header.d=espressif.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=espressifsystems.onmicrosoft.com; s=selector1-espressifsystems-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=V4YMvvXX/RK1MBaA8c1QmaZ0tah/LVEUR7KGBeELGkI=; b=u8HO/VNeFfchRx3AC8aBFgABeqhWCNrb3rbOpNCUfjbUwvj71AWi5/TZZqKVL+YlwRbh4UE4t8l0UJIyBoJQwYgETZSszQ1ibRir5bEdmhqYFcFJ0jlo6BAYXaCQChzn9p16KsxRN15MBSQSsFMLJlMUHb0CjDoT5ZU5Fnbr3Lk= Received: from TYZPR04MB5736.apcprd04.prod.outlook.com (2603:1096:400:1fa::7) by SI2PR04MB5622.apcprd04.prod.outlook.com (2603:1096:4:1a1::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9052.20; Mon, 25 Aug 2025 12:20:03 +0000 Received: from TYZPR04MB5736.apcprd04.prod.outlook.com ([fe80::6d6:9923:c880:a521]) by TYZPR04MB5736.apcprd04.prod.outlook.com ([fe80::6d6:9923:c880:a521%2]) with mapi id 15.20.9052.019; Mon, 25 Aug 2025 12:20:03 +0000 From: Alexey Lapshin <alexey.lapshin@espressif.com> To: "newlib@sourceware.org" <newlib@sourceware.org> CC: Alexey Gerenkov <alexey.gerenkov@espressif.com>, Konstantin Kondrashov <konstantin.kondrashov@espressif.com> Subject: [PATCH] RISC-V: strcpy size optimized: do not compile unreacheble code Thread-Topic: [PATCH] RISC-V: strcpy size optimized: do not compile unreacheble code Thread-Index: AQHcFbqVeC6qg/mVMEWpuDm/UVyXkw== Date: Mon, 25 Aug 2025 12:20:03 +0000 Message-ID: <09b3c02087c1bdaa27c9caa103be363cd2ce2af4.camel@espressif.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=espressif.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: TYZPR04MB5736:EE_|SI2PR04MB5622:EE_ x-ms-office365-filtering-correlation-id: 08dae377-517c-42b9-4c2f-08dde3d1b815 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|10070799003|1800799024|366016|376014|38070700018; x-microsoft-antispam-message-info: =?utf-8?q?dGSg1e6MtIfh8jJj/huTX6oFkFuebMh?= =?utf-8?q?Xl6SODN2p9sgcTlYfVMyprsW1d8ZwbXgg5N7SfMiB54u/RpB59XyWeM+IKs4Apyur?= =?utf-8?q?gxWmWwZg2hKiQPnvT7zx4fvfeJwHTkvdsL4i/prmhGuSbpeg5JgFyQsCDVxA0sXsb?= =?utf-8?q?kf2E/S/O33HBJeRD3dr/tQe89KZWa3w3Bls64RNfd7/YCzoYEQKQR4zjrc9171oIK?= =?utf-8?q?uXe2+QPMrIGb/8roEIBGJvD66GQjzXag862Jr+zx1DIyYZb1I07TUKG4uVnqJ3sau?= =?utf-8?q?gqAeD+mI7c3uvrLRcDiyA63DgQurbPr4vcOtdA96zr2ac+8nKjK8QA8ZNRHSN1uqc?= =?utf-8?q?zenKEss3NJkL/K/doiR4R3jvnUYECED0pcO9MtPlH925piVFknReI+pgOgLvs9Ijn?= =?utf-8?q?KTiL5tlTqCM7O35KBaYRUudIMEKSN4r4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jJXTEO+EMsfgMyhJFV+VyzKlDyJVUom?= =?utf-8?q?EijKefDCxOTelHbNDccEvIWIwQL9dou59JeGJezqlRX9jDAdDQACU3AjKx7+9LkcG?= =?utf-8?q?B2LlbjW1D2yhNuY0AEcJfaytfayNw1BBA=3D=3D?= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:TYZPR04MB5736.apcprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(10070799003)(1800799024)(366016)(376014)(38070700018); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?jlkb0LHORVVoaK3ZgvJFm4Cl04g8?= =?utf-8?q?weXH3XhkhgDq1EJvfWVDimrg1VjxiQoaaQxLsJIsfHrRxAEwEf3ZOzu0bgIyHDHfG?= =?utf-8?q?3KJ87EzAjGl5Gc8jCL9wEk5QlRALN32tZSbihrRzfHIitR+80jjr/91pBPzv+X/R5?= =?utf-8?q?uAbcy42f14iKvWgC7m/GgG23REYunNLhtRYkdeBH7OLFJtrN6AN5jdEV85fAyX0Ti?= =?utf-8?q?sOpLIQxA6VVSJ5h130xdl9JENY69iS7BtVy8zkafDbM8eScqRNj5fZZMa0hQzcMr6?= =?utf-8?q?MpN1001rBr6xcwbm9j+rppOXByK1r0arpnEOWfLSomQKKMl7oPNjN094OUryPvw3m?= =?utf-8?q?3wDH4S1gpsREKg+yetcKdelX2Rm+5vF2ybHn2Wplfk3KVMC4p5HOuRSncSO/D2h/A?= =?utf-8?q?eTCbsVxYhmyzRpQcNXlF3QJOOgQUOaRkAJUvyhzYxumt3Q9HQ54km1reuHnCnkCRI?= =?utf-8?q?7EDPpye2z8BWUN+7Q4Gqv3cOsINnk0DReEQ2+Met/Niej2p7bOiN7AMnxL1na10Zt?= =?utf-8?q?YTkBSeBnfndS/gJdnbT3f+SJx4a164TNaGQIp7kl9Dm1cdzUGU6cG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CHw?= =?utf-8?q?s5EfSg9MeysHpTiSGUmIYO51Int/O7HZqTv6mc8ACLU6qENNh1UNsbAnTBAP4gpYe?= =?utf-8?q?Mkvao9BtnF695PiByWbggAP4q6J6YdTmv3X8L2WmCNhUOozyWGsmn2axEHwXQGzvi?= =?utf-8?q?0t6oFQsTsnb/tMlOh7UwuKgdFxV6sITuU/QyZ3e7+5pMgPgY5thNNA=3D?= Content-Type: text/plain; charset="utf-8" Content-ID: <3763549C8D614B469A71D9859575D220@apcprd04.prod.outlook.com> Content-Transfer-Encoding: base64 MIME-Version: 1.0 X-OriginatorOrg: espressif.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: TYZPR04MB5736.apcprd04.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 08dae377-517c-42b9-4c2f-08dde3d1b815 X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Aug 2025 12:20:03.2427 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 5faf27fd-3557-4294-9545-8ea74a409f39 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: kV7fTdTh1Sg6uuDr63YFh8fVqMTGE+2MbHcvnilaNyVJFIFLKdU+gLpF3nDbGTqkQcjZYbyoip/6pyDLSV+5WcmE5OHDnxElA3JVi2yc5WY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SI2PR04MB5622 X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED, 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 X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Newlib mailing list <newlib.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/newlib>, <mailto:newlib-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/newlib/> List-Post: <mailto:newlib@sourceware.org> List-Help: <mailto:newlib-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/newlib>, <mailto:newlib-request@sourceware.org?subject=subscribe> Errors-To: newlib-bounces~patchwork=sourceware.org@sourceware.org |
| Series |
RISC-V: strcpy size optimized: do not compile unreacheble code
|
|
Commit Message
Alexey Lapshin
Aug. 25, 2025, 12:20 p.m. UTC
If misaligned access is allowed on the target machine, there is no need
to compile the byte-to-byte copy loop at the end of the strcpy function.
All bytes are already in place due to the earlier logic.
Signed-off-by: Konstantin Kondrashov <konstantin@espressif.com>
---
newlib/libc/machine/riscv/rv_string.h | 3 +++
1 file changed, 3 insertions(+)
--
2.43.0
Comments
Hi Alexey, Could you please reformat the condition to avoid double negatives? -- Jeff J. On Mon, Aug 25, 2025 at 8:20 AM Alexey Lapshin <alexey.lapshin@espressif.com> wrote: > If misaligned access is allowed on the target machine, there is no need > to compile the byte-to-byte copy loop at the end of the strcpy function. > All bytes are already in place due to the earlier logic. > > Signed-off-by: Konstantin Kondrashov <konstantin@espressif.com> > --- > newlib/libc/machine/riscv/rv_string.h | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/newlib/libc/machine/riscv/rv_string.h > b/newlib/libc/machine/riscv/rv_string.h > index dc2a26daf..9f5eb4099 100644 > --- a/newlib/libc/machine/riscv/rv_string.h > +++ b/newlib/libc/machine/riscv/rv_string.h > @@ -112,6 +112,8 @@ static __inline char *__libc_strcpy(char *dst, const > char *src, bool ret_start) > } > #endif /* not PREFER_SIZE_OVER_SPEED */ > > +#if !(!defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__) && > + !(__riscv_misaligned_slow || __riscv_misaligned_fast)) > char ch; > do > { > @@ -122,6 +124,7 @@ static __inline char *__libc_strcpy(char *dst, const > char *src, bool ret_start) > } while (ch); > > return ret_start ? dst0 : dst - 1; > +#endif > } > > > -- > 2.43.0 > >
diff --git a/newlib/libc/machine/riscv/rv_string.h b/newlib/libc/machine/riscv/rv_string.h index dc2a26daf..9f5eb4099 100644 --- a/newlib/libc/machine/riscv/rv_string.h +++ b/newlib/libc/machine/riscv/rv_string.h @@ -112,6 +112,8 @@ static __inline char *__libc_strcpy(char *dst, const char *src, bool ret_start) } #endif /* not PREFER_SIZE_OVER_SPEED */ +#if !(!defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__) && + !(__riscv_misaligned_slow || __riscv_misaligned_fast)) char ch; do { @@ -122,6 +124,7 @@ static __inline char *__libc_strcpy(char *dst, const char *src, bool ret_start) } while (ch); return ret_start ? dst0 : dst - 1; +#endif }