[llvm-dev] Code generation option for wide integers on x86_64?

Philip Reames via llvm-dev llvm-dev at lists.llvm.org
Mon Aug 17 13:01:04 PDT 2020


I'll comment that I'd love to see someone improve LLVM's lowering for 
wide integers, but this definitely falls into the "interesting project" 
camp, not the "fastest way to make progress" camp.

Philip

On 8/17/20 12:08 PM, Eli Friedman via llvm-dev wrote:
>
> If you’re dealing with integers that wide, I’d recommend avoiding the 
> builtin IR integers.  There are dedicated libraries for wide integers; 
> the most well-known is probably GMP.
>
> -Eli
>
> *From:* llvm-dev <llvm-dev-bounces at lists.llvm.org> *On Behalf Of 
> *Riyaz Puthiyapurayil via llvm-dev
> *Sent:* Monday, August 17, 2020 11:54 AM
> *To:* llvm-dev <llvm-dev at lists.llvm.org>
> *Subject:* [EXT] [llvm-dev] Code generation option for wide integers 
> on x86_64?
>
> Is there an existing option in X86_64 target code generator to emit a 
> loop for the following code:
>
> define i4096 @add(i4096 %a, i4096 %b) *alwaysinline* {
>
>     %c = add i4096 %a, %b
>
>     ret i4096 %c
>
> }
>
> instead of:
>
>      movq %rdi, %rax
>
>      addq 96(%rsp), %rsi
>
>      adcq 104(%rsp), %rdx
>
>      movq %rdx, 8(%rdi)
>
>      movq %rsi, (%rdi)
>
>      adcq 112(%rsp), %rcx
>
>      movq %rcx, 16(%rdi)
>
>      adcq 120(%rsp), %r8
>
>      movq %r8, 24(%rdi)
>
>      adcq 128(%rsp), %r9
>
>      movq %r9, 32(%rdi)
>
>      movq 8(%rsp), %rcx
>
>      adcq 136(%rsp), %rcx
>
>      movq %rcx, 40(%rdi)
>
>      movq 16(%rsp), %rcx
>
>            :
>
>      :
>
>      :
>
> What is the best strategy for lowering wide integer types/operations 
> on x86_64 without causing code blow up? Should we the code run through 
> a custom pass that replaces wide operations with a library function 
> call (or alternatively a loop) before code generation? Is there any 
> existing code that can be reused?
>
> Is there any documentation that describe strategies for lowering from 
> languages that support arbitrarily wide integers?
>
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200817/890c6d12/attachment.html>


More information about the llvm-dev mailing list