summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2015-11-01 12:12:41 +0100
committercinap_lenrek <cinap_lenrek@felloff.net>2015-11-01 12:12:41 +0100
commita4e32b43eae351f50d534927b97c4c27a7657418 (patch)
tree2546f2b9e5ba42e8e623d105d68e378ac853e3c4
parentd901fbe4f1e7191b757355384504d7560e8d040e (diff)
downloadplan9front-a4e32b43eae351f50d534927b97c4c27a7657418.tar.xz
libmp: optimize case x/0xffffffff in mpdigdiv() (helps arm)
-rw-r--r--sys/src/libmp/port/mpdigdiv.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/sys/src/libmp/port/mpdigdiv.c b/sys/src/libmp/port/mpdigdiv.c
index 4a73bb3a4..32b166765 100644
--- a/sys/src/libmp/port/mpdigdiv.c
+++ b/sys/src/libmp/port/mpdigdiv.c
@@ -21,6 +21,19 @@ mpdigdiv(mpdigit *dividend, mpdigit divisor, mpdigit *quotient)
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;