aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/runtime/runtime.c
diff options
context:
space:
mode:
authorRémy Oudompheng <oudomphe@phare.normalesup.org>2013-07-31 23:37:23 +0200
committerRémy Oudompheng <oudomphe@phare.normalesup.org>2013-07-31 23:37:23 +0200
commita05237f20ae6230238a9e44bc8bfc974e6d51422 (patch)
tree3e1c0471fb6cecaebfab10d9bd70c6907bc350bf /src/pkg/runtime/runtime.c
parent727901410a9394b5c6d8f844321eb651cfa4abca (diff)
downloadgo-a05237f20ae6230238a9e44bc8bfc974e6d51422.tar.xz
runtime: save 8 stack bytes in timediv on arm.
Operations on int64 are very stack consuming with 5c. Fixes netbsd/arm build. Before: TEXT runtime.timediv+0(SB),7,$52-16 After: TEXT runtime.timediv+0(SB),7,$44-16 The stack usage is unchanged on 386: TEXT runtime.timediv+0(SB),7,$8-16 R=golang-dev, dvyukov, bradfitz CC=golang-dev https://golang.org/cl/12182044
Diffstat (limited to 'src/pkg/runtime/runtime.c')
-rw-r--r--src/pkg/runtime/runtime.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/pkg/runtime/runtime.c b/src/pkg/runtime/runtime.c
index 5bca6f87b4..a0e9a194c6 100644
--- a/src/pkg/runtime/runtime.c
+++ b/src/pkg/runtime/runtime.c
@@ -421,16 +421,16 @@ runtime·timediv(int64 v, int32 div, int32 *rem)
{
int32 res, bit;
- if(v >= div*0x7fffffffLL) {
+ if(v >= (int64)div*0x7fffffffLL) {
if(rem != nil)
*rem = 0;
return 0x7fffffff;
}
res = 0;
- for(bit = 0x40000000; bit != 0; bit >>= 1) {
- if(v >= (int64)bit*div) {
- v = v - (int64)bit*div;
- res += bit;
+ for(bit = 30; bit >= 0; bit--) {
+ if(v >= ((int64)div<<bit)) {
+ v = v - ((int64)div<<bit);
+ res += 1<<bit;
}
}
if(rem != nil)