[PATCH] D120329: [SelectionDAG] Emit calls to __divei4 and friends for division/remainder of large integers

Matthias Gehre via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 23 05:43:08 PST 2022


mgehre-amd added inline comments.


================
Comment at: llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp:3949
+
+  return TLI.LowerCallTo(CLI).first;
+}
----------------
LuoYuanke wrote:
> I notice in RFC (https://discourse.llvm.org/t/rfc-add-support-for-division-of-large-bitint-builtins-selectiondag-globalisel-clang/60329) the prototype of the function is `void __udivei4(unsigned int *quo, unsigned int *a, unsigned int *b, unsigned int bits);`. I didn't find the code to pass `quo` and the code to load the value from `quo` after the call.
You are right, I did something stupid here. It turns out that I'm telling here that __udivei4 returns a `i256` (or similar) where instead the first argument is the output argument providing a `i256`.
In the assembly, both come out the same, so my tests worked. But I will change this here to clearly load back the result from the output parameter.


================
Comment at: llvm/test/CodeGen/X86/udivmodei5.ll:98
+; X64-NEXT:    callq __udivei4 at PLT
+; X64-NEXT:    movq {{[0-9]+}}(%rsp), %rcx
+; X64-NEXT:    andl $1, %ecx
----------------
LuoYuanke wrote:
> Is the result returned as value or from a pointer?
The result is written to the pointer given by the first argument. I.e. for `void __udivei4(unsigned int *quo, unsigned int *a, unsigned int *b, unsigned int bits)`, the result is stored to `quo`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120329



More information about the llvm-commits mailing list