[PATCH] D120327: compiler-rt: Add udivmodei5 to builtins and add bitint library

Jacob Lifshay via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 5 01:25:29 PDT 2022


programmerjake added a comment.

In D120327#3493181 <https://reviews.llvm.org/D120327#3493181>, @mgehre-amd wrote:

> In D120327#3492053 <https://reviews.llvm.org/D120327#3492053>, @efriedma wrote:
>
>> Instead of putting the `__divmodei5`/`__udivmodei5` routines in compiler-rt, can we just make the backend embed them into the object file?
>
> I agree for smaller builtin function. Here, I would need to check how much LLVM IR is necessary.

In the future we (LLVM) will probably want to switch the algorithm used to Knuth's Algorithm D, which is quite complex...I know I wouldn't want to try writing that in C++ that generates LLVM IR...it would probably be more than 2k lines of nearly incomprehensible code. Also, I expect specialization based on input/output sizes to not have much effect for Algorithm D, imho we should just have the generic functions and call them rather than generating a separate function per bit-width.

For an example of how complex it is, see the C code we (Libre-SoC) are currently working on to develop new instructions for OpenPower to accelerate big-int arithmetic:
ignore lines 236-402, they're `#ifdef`-ed out.
https://git.libre-soc.org/?p=libreriscv.git;a=blob;f=openpower/sv/biginteger/divmnu64.c;h=10b05d5aba2a857fac55f5873734a9f7fae257d3;hb=HEAD#l153
if you're curious, the instructions we're developing: https://libre-soc.org/openpower/sv/biginteger/


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D120327/new/

https://reviews.llvm.org/D120327



More information about the llvm-commits mailing list