Re: [PATCH v2 1/3] lib: extract 32bit mul/div helpers from nios2 into GENERIC_LIB
From: Vineet Gupta
Date: Sat Nov 07 2026 - 19:33:35 EST
On 11/6/26 05:07, Simon Schuster wrote:
Hello Vineet,
On Tue, Nov 03, 2026 at 08:23:23PM -0800, Vineet Gupta wrote:
As David has correctly pointed out, nios2 was dropped from gcc with+/*Shouldn't the 'u' prefixed functions have unsigned int args, result.
+ * Software 32-bit multiply for cores built without the hardware multiplier.
+ */
+s32 notrace __mulsi3(s32 a, s32 b);
+s32 notrace __divsi3(s32 a, s32 b);
+s32 notrace __udivsi3(s32 a, s32 b);
+s32 notrace __modsi3(s32 a, s32 b);
+s32 notrace __umodsi3(s32 a, s32 b);
It seems libgcc/?divmod.c doesn't but ARC does have nint_t for those which
is unsigned.
Nios it seems was removed from gcc?
release line 14.y being the last one to contain it.
So at least for nios2, it seems like it has always been the case that
__udivsi3/__umodsi3 were declared as taking and returning SItypes:
https://github.com/gcc-mirror/gcc/blob/releases/gcc-14/libgcc/config/nios2/lib2-divmod.c#L106
Given that both implementations continue to pass it through to a very
similarly looking udivmodsi4 as u32, I would assume that this has partly
relied on 'why should the compiler do any strange upcasts here, it will
just pass through the registers and be done with it and this is
implementation-defined-good-enough', so I would not mind rolling a v3
with u32s for __umodsi3 and __udivsi3. Are these the only two symbols
you are concerned about, and would these signatures work for you?
u32 notrace __udivsi3(u32 a, u32 b);
u32 notrace __umodsi3(u32 a, u32 b);
Yep that's what I had in my local version.
Thx,
-Vineet