ref: a4e32b43eae351f50d534927b97c4c27a7657418
parent: d901fbe4f1e7191b757355384504d7560e8d040e
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sun Nov 1 07:12:41 EST 2015
libmp: optimize case x/0xffffffff in mpdigdiv() (helps arm)
--- a/sys/src/libmp/port/mpdigdiv.c
+++ b/sys/src/libmp/port/mpdigdiv.c
@@ -21,6 +21,19 @@
return;
}
+ // very common case
+ if(~divisor == 0){
+ lo += hi;
+ if(lo < hi){
+ hi++;
+ lo++;
+ }
+ if(lo+1 == 0)
+ hi++;
+ *quotient = hi;
+ return;
+ }
+
// at this point we know that hi < divisor
// just shift and subtract till we're done
q = 0;