Re: [PATCH] MIPS: Fix the GCC version check for `__multi3' workaround
From: David Laight
Date: Mon Mar 30 2026 - 07:53:06 EST
On Mon, 30 Mar 2026 11:09:43 +0100 (BST)
"Maciej W. Rozycki" <macro@xxxxxxxxxxx> wrote:
> On Mon, 30 Mar 2026, David Laight wrote:
>
> > Although it might be worth just deleting the version check.
> > __multi3 is unconditionally defined for sparc64 and that is a much
> > more complex function rather than the pretty trivial mips64 version.
>
> We want to catch invalid usage or we could just link with libgcc.a.
That would pull in all sorts of expensive functions - like divides.
One option would be have a 'u128 mul_u64_u64_u128(u64, u64)' function
that architectures could define, defaulting to (u128)a * b.
Similar definitions exist for mixed u64/u32 arithmetic on 32bit because
gcc tends to make a proverbial 'pig's breakfast' of compiling it.
(I've seen explicit multiplies by constant zeros that have been spilled
to stack!)
I recently improved/optimised the nolibc snprintf() code; that fell over
the same problem (on both mips64 and sparc64) doing the div/rem by 10
using multiply by reciprocal. I'm not sure how the kernel snprintf()
does the conversion - the entire function needs some TLC.
(That would probably speed up things like 'cat /proc/interrupts'.)
David
>
> Maciej
>