Message ID | 20250410112308.77247-3-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 29CB638393A4 for <patchwork@sourceware.org>; Thu, 10 Apr 2025 11:28:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 29CB638393A4 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=AFfygjq2 X-Original-To: newlib@sourceware.org Delivered-To: newlib@sourceware.org Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by sourceware.org (Postfix) with ESMTPS id A2C583860758 for <newlib@sourceware.org>; Thu, 10 Apr 2025 11:23:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A2C583860758 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 A2C583860758 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::529 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1744284195; cv=none; b=YjeVqr2vg+OG0NONf2cKAFMLFBnj5JESxxAk64JWn5bTXU02JZMfL14Lk21OWtOZfsWZXV936+4ti7Wz9U38xzXmjq3snn7TrIP2Zj8ofOJofo+0tUa5f1Tqw/NMybOi9B0nWdjXfPs4z07irwClnZ1PkEqFVB8a/c/osC/b+fA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1744284195; c=relaxed/simple; bh=PzMKKbq9VQ6hfuv03HSl32Qqo6HPSJ/QL+PI4AWRV6w=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=gai9xE8gSnI/B3+wJtyAVZOKkw/SgwTge/PadWxhvB8h+ynM7vnKUYvXB4Xdil9QVFZ8motDEQk9rCLrUKV+J5askWC7qZfJvj5KeiJArGyjMca9FJG6fOccbMWdYdOnigkKL6ZYjW3Sk/vQpCp8MQjGoSXPeuAJxmT4c98KDCo= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A2C583860758 Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-5e60cfef9cfso1184616a12.2 for <newlib@sourceware.org>; Thu, 10 Apr 2025 04:23:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1744284194; x=1744888994; 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=wY7GCQu1BVch5XM7tCiBRkNvN+K/jwgfmanwxJg5rwQ=; b=AFfygjq2ofuZbP5Z3PPjXQqb5NTWXUL5MHQGCan9BRRNiqWwNW9UZAp9h4OD92kjkt zzyoeE/Sn6EdKgJBN6NeVxeQy80emVZivzMvbFdcc8DAkuviRZSYx0xaJidXcPh5r4vM apyfLbceladWwj5mmM8llFtZhNHPt5veXumOz05izjcUChMQ4V09qSk6sjJQ7anmzqnH JAqsZBsWgVtomqrBxfU+dCFc//rb+P9jS80jK1yLMX/webtZI4aZuu4sUSaN7acDMPpH fOA4x2bUHXGb7pZyDDonIYW9Cf6zDQwmhkknzx+EWIbWTT0/3ZvT5YgU9fD83P3Y8/Zb tEYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744284194; x=1744888994; 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=wY7GCQu1BVch5XM7tCiBRkNvN+K/jwgfmanwxJg5rwQ=; b=KM1ni0crVZ6Y/yu4zWJ7eL5TsGnjjUVeMGJKcEGiGLfljx8XSI+pcJZPTl/eeUPoz7 +hPuoKPsK5RJJFz8bzfcrqIyfYLhccbzmD0nQcKQJAOr8OQEZ/r+JKa7+laYGFUbyWnh PZQZ/Wq6mLKXfiM47fV3txXBszR1JoaLk5QDY/HivtZy3ipeC46hpofKpATAtYOapGJ/ BpneeVV6wV0dVZK3rtFmCuya9QEU/H6P5vtrmUdGJwOyqwoVgQ+NVHuTjHUspKbTj4IN lyg2Y8ceYdVFsNihz0bieeX9/GLdjupT/Gv8C0olIyLQoWwnJQIl6xLCIE+X3B3ReM64 lrqg== X-Gm-Message-State: AOJu0YyRLI9vdZzkRkkFnRDGQPUQsh1PZjL2BSwp1rlOYdGwS7nQC4mL rDwsHdDtbAAzh4+LxzdMED5dDHP1l+j0LUim8gJUREKo9PDZWUEXCWCyw9I2 X-Gm-Gg: ASbGncuPMIj7pq8jALlaCzhz/1YdOZbTcA9a6qB+RsYt7lsANoZTGypKjUbcZr2a5WI 5yk4Uyy+ph8ea9gwyFyqyR6zEntuRteYgelU+b/VQUa+ky4p2IamhUu+F0EevHaC4pbN6JpSRhC pYKxXl122Q6PVlsDMvMUAqlpB070NCMLuc5geZmYcLnHSX3e2vsvH7b7W2ycruRpuHHojniKHz5 C9cvZQWH5SZIPRuU6Cn5R0+SPwJbmGOt1lqSQvonrNtC6VUfmEVJFyaud4clocUrqFZjtV6SVQ2 bI4hUYwzjxwmbYprxeO1OvX0sJN4ZQ+FyTbX6vSBpJmEl4IqzkWQtRoBur2tWzbsbIwmJdHuFuA jEr2yPAk= X-Google-Smtp-Source: AGHT+IHfzqSxooJmdaoH2zs7/5wwdny3ocdxG15FiWv4syDZT0kQlZg0AoFzUxDQ5ZpB2t3gtUrbww== X-Received: by 2002:a17:907:3d4d:b0:ac7:150b:57b2 with SMTP id a640c23a62f3a-acabd4cec55mr284034666b.41.1744284194042; Thu, 10 Apr 2025 04:23:14 -0700 (PDT) Received: from marlene-s-thinkpad.eduroam.tuwien.ac.at ([149.34.244.140]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5f2fbbac4c6sm2127973a12.13.2025.04.10.04.23.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Apr 2025 04:23: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 v2 02/11] RISC-V: memmove() size optimized version: Use compressed registers only Date: Thu, 10 Apr 2025 13:22:59 +0200 Message-ID: <20250410112308.77247-3-marlene.fally@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250410112308.77247-1-marlene.fally@gmail.com> References: <20250410112308.77247-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, SCC_5_SHORT_WORD_LINES, 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 10, 2025, 11:22 a.m. UTC
Change register t1 to register a4, so that the affected instructions can be compressed. Since now we have less registers available, the following changes need to be made: In the previous version of this function, a4 was used to hold the offset that needs to be added to source and destination addresses before copying any data in the case of source address > destination address. Since a4 now holds the destination address, this offset is not calculated anymore. Instead, the value in a2 (the number of bytes to be copied) is added to the source and destination addresses. Therefore, in the case of source address > destination adress, a value of 1 needs to be subtracted from both addresses before starting the copying process. Reviewed-by: Christian Herber <christian.herber@oss.nxp.com> Signed-off-by: m fally <marlene.fally@gmail.com> --- newlib/libc/machine/riscv/memmove.S | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/newlib/libc/machine/riscv/memmove.S b/newlib/libc/machine/riscv/memmove.S index 0f7216a68..123ab3834 100644 --- a/newlib/libc/machine/riscv/memmove.S +++ b/newlib/libc/machine/riscv/memmove.S @@ -16,22 +16,22 @@ memmove: beqz a2, 2f - mv t1, a0 + mv a4, a0 li a3, 1 bgtu a1, a0, 1f li a3, -1 - addi a4, a2 , -1 - add t1, t1, a4 - add a1, a1, a4 + add a4, a4, a2 + add a1, a1, a2 +3: + add a4, a4, a3 + add a1, a1, a3 1: lb a5, 0(a1) - sb a5, 0(t1) + sb a5, 0(a4) add a2, a2, -1 - add t1, t1, a3 - add a1, a1, a3 - bnez a2, 1b + bnez a2, 3b 2: ret