[PATCH] D87433: [builtins] Write __divmoddi4/__divmodsi4 in terms __udivmod instead of __div and multiply.

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 10 00:07:06 PDT 2020


MaskRay accepted this revision.
MaskRay added inline comments.
This revision is now accepted and ready to land.


================
Comment at: compiler-rt/lib/builtins/divmodsi4.c:19
 COMPILER_RT_ABI si_int __divmodsi4(si_int a, si_int b, si_int *rem) {
-  si_int d = __divsi3(a, b);
-  *rem = a - (d * b);
-  return d;
+  const int bits_in_word_m1 = (int)(sizeof(si_int) * CHAR_BIT) - 1;
+  si_int s_a = a >> bits_in_word_m1;                    // s_a = a < 0 ? -1 : 0
----------------
MaskRay wrote:
> Just `bits_in_word`? `m1` is not used.
ok, m1 means minus 1...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87433



More information about the llvm-commits mailing list