[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:06:28 PDT 2020
MaskRay added inline comments.
================
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
----------------
Just `bits_in_word`? `m1` is not used.
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