Hello everybody, I'm seeing LLVM (v 3.1) abort when trying to generate code that multiplies or divides 128-bit integers on x86-32. Here is a complete example function: define %jl_value_t* @foo564(%jl_value_t*, %jl_value_t**, i32) { top: %3 = load %jl_value_t** %1, align 4, !dbg !5139 %4 = getelementptr inbounds %jl_value_t* %3, i32 0, i32 0, !dbg !5139 %5 = getelementptr %jl_value_t** %4, i32 1, !dbg !5139 %6 = bitcast %jl_value_t** %5 to i128*, !dbg !5139 %7 = load i128* %6, align 4, !dbg !5139 %8 = mul i128 %7, 137, !dbg !5146, !julia_type !5147 %9 = call %jl_value_t* @allocobj(i32 20), !dbg !5146 %10 = getelementptr inbounds %jl_value_t* %9, i32 0, i32 0, !dbg !5146 store %jl_value_t* inttoptr (i32 159792480 to %jl_value_t*), %jl_value_t** %10, align 4, !dbg !5146 %11 = getelementptr %jl_value_t** %10, i32 1, !dbg !5146 %12 = bitcast %jl_value_t** %11 to i128*, !dbg !5146 store i128 %8, i128* %12, align 4, !dbg !5146 ret %jl_value_t* %9, !dbg !5146 } On JITing to native code, I get: UNREACHABLE executed! Stack dump: 0. Running pass 'X86 DAG->DAG Instruction Selection' on function '@foo564' Aborted Add and subtract seem to work fine. Is there anything I might be doing wrong? thanks, -Jeff
Hi Jeff,> I'm seeing LLVM (v 3.1) abort when trying to generate code that > multiplies or divides 128-bit integers on x86-32.this is a known issue. The runtime library (libgcc) has routines for dividing two 64-bit integers on x86-32, but not two 128-bit integers. At least, that is how it was last time I looked. To overcome this libgcc or LLVM's compiler-rt would need to get 128 bit division routines. Ciao, Duncan.> Here is a complete example function: > > define %jl_value_t* @foo564(%jl_value_t*, %jl_value_t**, i32) { > top: > %3 = load %jl_value_t** %1, align 4, !dbg !5139 > %4 = getelementptr inbounds %jl_value_t* %3, i32 0, i32 0, !dbg !5139 > %5 = getelementptr %jl_value_t** %4, i32 1, !dbg !5139 > %6 = bitcast %jl_value_t** %5 to i128*, !dbg !5139 > %7 = load i128* %6, align 4, !dbg !5139 > %8 = mul i128 %7, 137, !dbg !5146, !julia_type !5147 > %9 = call %jl_value_t* @allocobj(i32 20), !dbg !5146 > %10 = getelementptr inbounds %jl_value_t* %9, i32 0, i32 0, !dbg !5146 > store %jl_value_t* inttoptr (i32 159792480 to %jl_value_t*), > %jl_value_t** %10, align 4, !dbg !5146 > %11 = getelementptr %jl_value_t** %10, i32 1, !dbg !5146 > %12 = bitcast %jl_value_t** %11 to i128*, !dbg !5146 > store i128 %8, i128* %12, align 4, !dbg !5146 > ret %jl_value_t* %9, !dbg !5146 > } > > On JITing to native code, I get: > > UNREACHABLE executed! > Stack dump: > 0. Running pass 'X86 DAG->DAG Instruction Selection' on function '@foo564' > Aborted > > Add and subtract seem to work fine. > Is there anything I might be doing wrong? > > thanks, > > -Jeff > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
On Jun 22, 2012, at 12:38 AM, Duncan Sands <baldrick at free.fr> wrote:> Hi Jeff, > >> I'm seeing LLVM (v 3.1) abort when trying to generate code that >> multiplies or divides 128-bit integers on x86-32. > > this is a known issue. The runtime library (libgcc) has routines for dividing > two 64-bit integers on x86-32, but not two 128-bit integers. At least, that is > how it was last time I looked. To overcome this libgcc or LLVM's compiler-rt > would need to get 128 bit division routines.Said differently, what is needed is "quad word" implementations of these runtime helper routines. Right now, all we have are "double word" implementations that allow for either 64-bit math on 32-bit CPUs or 128-bit math on 64-bit CPUs. If you implement 128-bit support for 32-bit, then implementing 256-bit support for 64-bit machines should be trivial. :-) davez> > Ciao, Duncan. > >> Here is a complete example function: >> >> define %jl_value_t* @foo564(%jl_value_t*, %jl_value_t**, i32) { >> top: >> %3 = load %jl_value_t** %1, align 4, !dbg !5139 >> %4 = getelementptr inbounds %jl_value_t* %3, i32 0, i32 0, !dbg !5139 >> %5 = getelementptr %jl_value_t** %4, i32 1, !dbg !5139 >> %6 = bitcast %jl_value_t** %5 to i128*, !dbg !5139 >> %7 = load i128* %6, align 4, !dbg !5139 >> %8 = mul i128 %7, 137, !dbg !5146, !julia_type !5147 >> %9 = call %jl_value_t* @allocobj(i32 20), !dbg !5146 >> %10 = getelementptr inbounds %jl_value_t* %9, i32 0, i32 0, !dbg !5146 >> store %jl_value_t* inttoptr (i32 159792480 to %jl_value_t*), >> %jl_value_t** %10, align 4, !dbg !5146 >> %11 = getelementptr %jl_value_t** %10, i32 1, !dbg !5146 >> %12 = bitcast %jl_value_t** %11 to i128*, !dbg !5146 >> store i128 %8, i128* %12, align 4, !dbg !5146 >> ret %jl_value_t* %9, !dbg !5146 >> } >> >> On JITing to native code, I get: >> >> UNREACHABLE executed! >> Stack dump: >> 0. Running pass 'X86 DAG->DAG Instruction Selection' on function '@foo564' >> Aborted >> >> Add and subtract seem to work fine. >> Is there anything I might be doing wrong? >> >> thanks, >> >> -Jeff >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev