From: Thorsten Blum <thorsten.blum@linux.dev>
To: Russell King <linux@armlinux.org.uk>
Cc: Thorsten Blum <thorsten.blum@linux.dev>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: [RESEND PATCH] ARM: vfp: Improve data types in vfp_estimate_div128to64()
Date: Sun, 9 Feb 2025 09:21:01 +0100 [thread overview]
Message-ID: <20250209082101.3255-2-thorsten.blum@linux.dev> (raw)
The divisors mh and ml can both be u32 instead of u64.
Since do_div() implicitly casts the divisors from u64 to u32, changing
their data types to u32 also removes the following Coccinelle warnings
reported by do_div.cocci:
arch/arm/vfp/vfp.h:121:2-8: WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead.
arch/arm/vfp/vfp.h:135:2-8: WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead.
Use upper_32_bits() to compare 32-bit numbers instead of 64-bit numbers
and to prevent the warning:
left shift count >= width of type [-Wshift-count-overflow]
Compile-tested only.
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
arch/arm/vfp/vfp.h | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/arch/arm/vfp/vfp.h b/arch/arm/vfp/vfp.h
index e43a630f8a16..29073d89ef00 100644
--- a/arch/arm/vfp/vfp.h
+++ b/arch/arm/vfp/vfp.h
@@ -109,12 +109,13 @@ static inline u64 vfp_hi64multiply64(u64 n, u64 m)
static inline u64 vfp_estimate_div128to64(u64 nh, u64 nl, u64 m)
{
- u64 mh, ml, remh, reml, termh, terml, z;
+ u64 remh, reml, termh, terml, z;
+ u32 mh, ml;
if (nh >= m)
return ~0ULL;
mh = m >> 32;
- if (mh << 32 <= nh) {
+ if (mh <= upper_32_bits(nh)) {
z = 0xffffffff00000000ULL;
} else {
z = nh;
@@ -129,7 +130,7 @@ static inline u64 vfp_estimate_div128to64(u64 nh, u64 nl, u64 m)
add128(&remh, &reml, remh, reml, mh, ml);
}
remh = (remh << 32) | (reml >> 32);
- if (mh << 32 <= remh) {
+ if (mh <= upper_32_bits(remh)) {
z |= 0xffffffff;
} else {
do_div(remh, mh);
--
2.48.1
next reply other threads:[~2025-02-09 8:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-09 8:21 Thorsten Blum [this message]
-- strict thread matches above, loose matches on Subject: below --
2025-01-13 9:08 [RESEND PATCH] ARM: vfp: Improve data types in vfp_estimate_div128to64() Thorsten Blum
2024-07-10 0:34 Thorsten Blum
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=20250209082101.3255-2-thorsten.blum@linux.dev \
--to=thorsten.blum@linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
/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;
as well as URLs for NNTP newsgroup(s).