Sergey Yakoushkin
2010-Mar-17 20:32 UTC
[LLVMdev] llvm-gcc promotes i32 mul to i64 inside __muldi3
I'm building tool-chain for processor without integer MUL. So, I've defined __mulsi3 for integer multiplication (int32). Now I've got a problem with int64 multiplication which is implemented in libgcc2.c. Segfualt due to infinite recursion in i64 soft multiplication (libgcc2, __muldi3). LLVM-GCC (for my target) misoptimizes code if -O2 is passed. It promotes i32 multiplication to int64 multiplication and as the result my back-end generates __muldi3 call. I would appreciate if someone can point out where this promotion happens. And how can I disable it? Thanks in advance. ... some code examples. __muldi3 (defined in llvm-gcc/gcc/libgcc2.c): w.s.high += ((UWtype) uu.s.low * (UWtype) vv.s.high + (UWtype) uu.s.high * (UWtype) vv.s.low); llvm asm compiled with llvm-gcc -O2: %20 = zext i32 %19 to i64 ; <i64> #uses=1 %21 = zext i32 %16 to i64 ; <i64> #uses=1 %22 = mul i64 %sroa.store.elt3, %u ; <i64> #uses=1 %23 = mul i64 %sroa.store.elt, %v ; <i64> #uses=1 %24 = add i64 %22, %23 ; <i64> #uses=1 %25 = add i64 %24, %21 ; <i64> #uses=1 %26 = shl i64 %25, 32 ; <i64> #uses=1 Regards, Sergey Y.
Eli Friedman
2010-Mar-17 20:54 UTC
[LLVMdev] llvm-gcc promotes i32 mul to i64 inside __muldi3
On Wed, Mar 17, 2010 at 1:32 PM, Sergey Yakoushkin <sergey.yakoushkin at gmail.com> wrote:> I'm building tool-chain for processor without integer MUL. > So, I've defined __mulsi3 for integer multiplication (int32). > > Now I've got a problem with int64 multiplication which is implemented > in libgcc2.c. > Segfualt due to infinite recursion in i64 soft multiplication > (libgcc2, __muldi3).See http://llvm.org/bugs/show_bug.cgi?id=3101 which is essentially the same issue. -Eli
Andrew Lenharth
2010-Mar-17 21:17 UTC
[LLVMdev] llvm-gcc promotes i32 mul to i64 inside __muldi3
On Wed, Mar 17, 2010 at 3:54 PM, Eli Friedman <eli.friedman at gmail.com> wrote:> On Wed, Mar 17, 2010 at 1:32 PM, Sergey Yakoushkin > <sergey.yakoushkin at gmail.com> wrote: >> I'm building tool-chain for processor without integer MUL. >> So, I've defined __mulsi3 for integer multiplication (int32). >> >> Now I've got a problem with int64 multiplication which is implemented >> in libgcc2.c. >> Segfualt due to infinite recursion in i64 soft multiplication >> (libgcc2, __muldi3). > > See http://llvm.org/bugs/show_bug.cgi?id=3101 which is essentially the > same issue.Alpha has the same problem with 128 Ints, in about the same functions.
Possibly Parallel Threads
- [LLVMdev] llvm-gcc promotes i32 mul to i64 inside __muldi3
- [LLVMdev] llvm-gcc promotes i32 mul to i64 inside __muldi3
- [LLVMdev] llvm-gcc promotes i32 mul to i64 inside __muldi3
- [LLVMdev] llvm-gcc promotes i32 mul to i64 inside __muldi3
- [LLVMdev] llvm-gcc promotes i32 mul to i64 inside __muldi3