diff --git a/compiler-rt/lib/builtins/udivdi3.c b/compiler-rt/lib/builtins/udivdi3.c --- a/compiler-rt/lib/builtins/udivdi3.c +++ b/compiler-rt/lib/builtins/udivdi3.c @@ -15,5 +15,26 @@ // Returns: a / b COMPILER_RT_ABI du_int __udivdi3(du_int a, du_int b) { - return __udivmoddi4(a, b, 0); + if (b == 0) + return -1; + du_int result = 0; + du_int j = 1; + // find max divisor which is less than dividend + while (a > b && b < b << 1) { + j = j << 1; + b = b << 1; + } + if (a < b) { + j = j >> 1; + b = b >> 1; + } + while (j != 0) { + if (a >=b ) { + a -= b; + result |= j; + } + b = b >> 1; + j = j>> 1; + } + return result; }