From: Nicolas Pitre <nico@fluxnic.net>
To: Arnd Bergmann <arnd@arndb.de>, Russell King <linux@armlinux.org.uk>
Cc: Nicolas Pitre <npitre@baylibre.com>,
linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v4 3/4] ARM: div64: improve __arch_xprod_64()
Date: Thu, 3 Oct 2024 17:16:15 -0400 [thread overview]
Message-ID: <20241003211829.2750436-4-nico@fluxnic.net> (raw)
In-Reply-To: <20241003211829.2750436-1-nico@fluxnic.net>
From: Nicolas Pitre <npitre@baylibre.com>
Let's use the same criteria for overflow handling necessity as the
generic code.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
---
arch/arm/include/asm/div64.h | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/arch/arm/include/asm/div64.h b/arch/arm/include/asm/div64.h
index 4b69cf8504..562d5376ae 100644
--- a/arch/arm/include/asm/div64.h
+++ b/arch/arm/include/asm/div64.h
@@ -56,6 +56,8 @@ static inline uint64_t __arch_xprod_64(uint64_t m, uint64_t n, bool bias)
{
unsigned long long res;
register unsigned int tmp asm("ip") = 0;
+ bool no_ovf = __builtin_constant_p(m) &&
+ ((m >> 32) + (m & 0xffffffff) < 0x100000000);
if (!bias) {
asm ( "umull %Q0, %R0, %Q1, %Q2\n\t"
@@ -63,7 +65,7 @@ static inline uint64_t __arch_xprod_64(uint64_t m, uint64_t n, bool bias)
: "=&r" (res)
: "r" (m), "r" (n)
: "cc");
- } else if (!(m & ((1ULL << 63) | (1ULL << 31)))) {
+ } else if (no_ovf) {
res = m;
asm ( "umlal %Q0, %R0, %Q1, %Q2\n\t"
"mov %Q0, #0"
@@ -80,7 +82,7 @@ static inline uint64_t __arch_xprod_64(uint64_t m, uint64_t n, bool bias)
: "cc");
}
- if (!(m & ((1ULL << 63) | (1ULL << 31)))) {
+ if (no_ovf) {
asm ( "umlal %R0, %Q0, %R1, %Q2\n\t"
"umlal %R0, %Q0, %Q1, %R2\n\t"
"mov %R0, #0\n\t"
--
2.46.1
next prev parent reply other threads:[~2024-10-03 21:18 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-03 21:16 [PATCH v4 0/4] simplify do_div() with constant divisor Nicolas Pitre
2024-10-03 21:16 ` [PATCH v4 1/4] lib/math/test_div64: add some edge cases relevant to __div64_const32() Nicolas Pitre
2024-10-03 21:16 ` [PATCH v4 2/4] asm-generic/div64: optimize/simplify __div64_const32() Nicolas Pitre
2024-10-04 22:47 ` kernel test robot
2024-10-03 21:16 ` Nicolas Pitre [this message]
2024-10-03 21:16 ` [PATCH v4 4/4] __arch_xprod64(): make __always_inline when optimizing for performance Nicolas Pitre
2024-10-04 13:25 ` [PATCH v4 0/4] simplify do_div() with constant divisor Arnd Bergmann
2024-10-26 0:36 ` Nicolas Pitre
2024-10-26 10:04 ` Arnd Bergmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241003211829.2750436-4-nico@fluxnic.net \
--to=nico@fluxnic.net \
--cc=arnd@arndb.de \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=npitre@baylibre.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®