Message ID | 20250409064701.3435-7-marlene.fally@gmail.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 1F373384DEDA for <patchwork@sourceware.org>; Wed, 9 Apr 2025 06:57:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1F373384DEDA Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=QP2be+V6 X-Original-To: newlib@sourceware.org Delivered-To: newlib@sourceware.org Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by sourceware.org (Postfix) with ESMTPS id A70FE384F00A for <newlib@sourceware.org>; Wed, 9 Apr 2025 06:47:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A70FE384F00A Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A70FE384F00A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::532 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1744181235; cv=none; b=fLIBBekmwWmCJ30bwva0Xh5gIA2hxcnQGfkZxzSz+YmFx2Pqu4vFPq3LDd2a6bsCEnAvu7Nh3Uw8EltDpKwc4llqItiTak+6dubSGixGs8apyDV1liXlGLvZEB4P+l3wX0UrFaZwhGu6ppjbpplSldBGgC5w/opEFX9MCNZqYMI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1744181235; c=relaxed/simple; bh=5nj+E0ro3Yki8KBcN8HKIbAGSbpIIDa4YLZQbW91koA=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=rYkZQDtgqMFKFB8JenV7IDkvB8YHhPvOhYom/rD+E2C/iacdI6uhlmCQDsn0xOsPAeQXbLgiO9bVsDD92wTWEYilW+Hp90clHagcIAKUhlMU3zqp+/N2SVdYM/Ut8fA8HIQKD8PKt+KbJLZZPDsusVIcirjLaX3wL+LpBOE6cu0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A70FE384F00A Received: by mail-ed1-x532.google.com with SMTP id 4fb4d7f45d1cf-5e5cd420781so11592509a12.2 for <newlib@sourceware.org>; Tue, 08 Apr 2025 23:47:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1744181234; x=1744786034; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2I91R3J3r5rlDThRQablZpH7ovCcxQkwrEnBQFAhhiQ=; b=QP2be+V67Lvjtsq+kGJ3EMfG+80J2KXHcTMAX/OtxYUKkAEKf1LiCr+/b15ZcPoqGj cIGTfbsHeA7wP8TM0ebcBep9J+1oJab3jg8C+N95oui5APltYJ4AGCIMByCBJwAzlbXT 0nWKlWmOC/0UPvNO7Qd9RrTKxR9rSaC3je9uRb6C+ScrPf0VFuI/pLDz9WK/HkmRXTYG mThfAiaQXxJwVNlScBon36AWZCSagzS6h6D6aLW2JeF8itHw0Hx4zwphyjF3YbREuU2o G+MIO1Tfqu+8I8gK8adhfj8byLfT99ahlLpoKby807mA/zgfxYhuL5UpBwUJAF4Re06U k+/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744181234; x=1744786034; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2I91R3J3r5rlDThRQablZpH7ovCcxQkwrEnBQFAhhiQ=; b=lxy2JzlhzsiBmQ3cQE7mFFC/WL3jD2e2OJoYEiI3vQy4wWO29CbAn1xKpHgef0I4Ve CjF+IFUPcRr7rQWEkQNSBq278ImENhQzCp5/Q6IQJJ1JNEJ2sbLbUdB7g4OM5c7NWQ0S uMliXzPLEUW0DV3V9Ext+wSnkUutuMCslZvGwhFjPb10yIF+4ML5IYyiZuBbV5vGmpsK fbedog8c3Ny6jkw3Xd28sUzHITc6feOIFsCtnjCh1UM0NPtGWft26Yh1kMnVwP+LBb43 bTDCszjNROssx88Ek24lUCBY4OeuTh8TDdq92jsPo5cYUzDYrJXwdKj32GstQX4ANvnO ccSA== X-Gm-Message-State: AOJu0YwOlsT7BJffk4EjQXlolc8Ls+4uzUPdsviMEUP6jhJA4FawHMmP PxdKQssgGYVMSlmjhkD/vLP7X2xcF8fLBlAirZaPGUpeRYCML+NIdL2bS6eznvg= X-Gm-Gg: ASbGncunDUXHKxBeG0UvHf9k2VBI6B7iy2b6Umj5mNkg8SGcrQ0mMynNVdR5sAo2led 8pYgXASVeIBImbrv+A3wzmJY7a9Y/Czd2aPT7AkZ4SF6nGH+B/PX0NmP3chuM/2VWieHrpf9ca9 rYXI2q7v5DZt2AlDtnT/E/UKtvai3DTOK+2MAN1fkGIpjdwg//2vPEeYRxHLsvQ+YiWxS5aGolx uoGejZrsyTb+c0Aal9vQWFHOFAU/vzv2j5WGvW1wtWjhSJNcSowte11QrKdEb3PhEIRsHd+1kYy NwO9QZjAB95t6qm+0mTy0ybyojIUXEgQBWtbtBT7ajM6ZT+K696EdXV3cNs= X-Google-Smtp-Source: AGHT+IHSUPTSlLcYJ3mwlkJb+xF2Lv/2LEoiO4Nemz6Rx2bt3B+g8lce46kXvxMhVxN5y+h6kpQATQ== X-Received: by 2002:a05:6402:241f:b0:5e0:60ed:f355 with SMTP id 4fb4d7f45d1cf-5f2f76e6812mr1579436a12.18.1744181234051; Tue, 08 Apr 2025 23:47:14 -0700 (PDT) Received: from localhost.localdomain ([2001:4bc9:a46:d00f:b073:3e3:923:aedd]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5f2fbc2cf69sm318413a12.37.2025.04.08.23.47.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Apr 2025 23:47:13 -0700 (PDT) From: m fally <marlene.fally@gmail.com> To: newlib@sourceware.org Cc: m fally <marlene.fally@gmail.com>, Christian Herber <christian.herber@oss.nxp.com> Subject: [PATCH 06/12] RISC-V: memmove() size optimized version: Relax RAW dependency Date: Wed, 9 Apr 2025 08:46:55 +0200 Message-ID: <20250409064701.3435-7-marlene.fally@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250409064701.3435-1-marlene.fally@gmail.com> References: <20250409064701.3435-1-marlene.fally@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, 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 |
newlib: RISC-V: Optimize memory and string functions for code size
|
|
Commit Message
m fally
April 9, 2025, 6:46 a.m. UTC
Move the instruction that increments the remaining number of bytes to be copied inbetween the load and store instructions. This is done in order to relax the RAW dependency between the load and store instructions. Reviewed-by: Christian Herber <christian.herber@oss.nxp.com> Signed-off-by: m fally <marlene.fally@gmail.com> --- newlib/libc/machine/riscv/memmove.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Comments
LGTM On Wed, Apr 9, 2025 at 2:57 PM m fally <marlene.fally@gmail.com> wrote: > > Move the instruction that increments the remaining number of > bytes to be copied inbetween the load and store instructions. > This is done in order to relax the RAW dependency between the > load and store instructions. > > Reviewed-by: Christian Herber <christian.herber@oss.nxp.com> > Signed-off-by: m fally <marlene.fally@gmail.com> > --- > newlib/libc/machine/riscv/memmove.S | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/newlib/libc/machine/riscv/memmove.S b/newlib/libc/machine/riscv/memmove.S > index 671a6a158..6ecad9ad6 100644 > --- a/newlib/libc/machine/riscv/memmove.S > +++ b/newlib/libc/machine/riscv/memmove.S > @@ -28,9 +28,9 @@ memmove: > add a4, a4, a3 /* in case of source address < destination address, increment both addresses by -1 before copying any data to obtain the correct start addresses */ > add a1, a1, a3 > .Lcopy: > - lbu a5, 0(a1) /* copy bytes as long as a2 (= the number of bytes to be copied) > 0 */ > + lbu a5, 0(a1) > + add a2, a2, -1 /* copy bytes as long as a2 (= the number of bytes to be copied) > 0. the increment is done here to relax the RAW dependency between load and store */ > sb a5, 0(a4) > - add a2, a2, -1 > bnez a2, .Lincrement > > .Ldone: > -- > 2.49.0 >
diff --git a/newlib/libc/machine/riscv/memmove.S b/newlib/libc/machine/riscv/memmove.S index 671a6a158..6ecad9ad6 100644 --- a/newlib/libc/machine/riscv/memmove.S +++ b/newlib/libc/machine/riscv/memmove.S @@ -28,9 +28,9 @@ memmove: add a4, a4, a3 /* in case of source address < destination address, increment both addresses by -1 before copying any data to obtain the correct start addresses */ add a1, a1, a3 .Lcopy: - lbu a5, 0(a1) /* copy bytes as long as a2 (= the number of bytes to be copied) > 0 */ + lbu a5, 0(a1) + add a2, a2, -1 /* copy bytes as long as a2 (= the number of bytes to be copied) > 0. the increment is done here to relax the RAW dependency between load and store */ sb a5, 0(a4) - add a2, a2, -1 bnez a2, .Lincrement .Ldone: