diff options
author | Russ Cox <rsc@golang.org> | 2015-07-30 10:54:53 -0400 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2015-07-30 15:48:29 +0000 |
commit | c9d2c7f0d26a9619069a3cb2291333174b6db63f (patch) | |
tree | b7f8960efe1ef2cccb7c5e495f5558ffc5be24cb /src/runtime/vlop_arm_test.go | |
parent | a1e422071cd8122b4b93bbdeb02d0ea646519955 (diff) | |
download | go-c9d2c7f0d26a9619069a3cb2291333174b6db63f.tar.gz go-c9d2c7f0d26a9619069a3cb2291333174b6db63f.zip |
runtime: replace divide with multiply in runtime.usleep on arm
We want to adjust the DIV calling convention to use m,
and usleep can be called without an m, so switch to a
multiplication by the reciprocal (and test).
Step toward a fix for #6699 and #10486.
Change-Id: Iccf76a18432d835e48ec64a2fa34a0e4d6d4b955
Reviewed-on: https://go-review.googlesource.com/12898
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/runtime/vlop_arm_test.go')
-rw-r--r-- | src/runtime/vlop_arm_test.go | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/runtime/vlop_arm_test.go b/src/runtime/vlop_arm_test.go index cd28419adf..1a211196f2 100644 --- a/src/runtime/vlop_arm_test.go +++ b/src/runtime/vlop_arm_test.go @@ -4,7 +4,10 @@ package runtime_test -import "testing" +import ( + "runtime" + "testing" +) // arm soft division benchmarks adapted from // http://ridiculousfish.com/files/division_benchmarks.tar.gz @@ -68,3 +71,14 @@ func BenchmarkUint32Mod13307(b *testing.B) { bmUint32Mod(13307, b) } func BenchmarkUint32Mod52513(b *testing.B) { bmUint32Mod(52513, b) } func BenchmarkUint32Mod60978747(b *testing.B) { bmUint32Mod(60978747, b) } func BenchmarkUint32Mod106956295(b *testing.B) { bmUint32Mod(106956295, b) } + +func TestUsplit(t *testing.T) { + var den uint32 = 1000000 + for _, x := range []uint32{0, 1, 999999, 1000000, 1010101, 0xFFFFFFFF} { + q1, r1 := runtime.Usplit(x) + q2, r2 := x/den, x%den + if q1 != q2 || r1 != r2 { + t.Errorf("%d/1e6, %d%%1e6 = %d, %d, want %d, %d", x, x, q1, r1, q2, r2) + } + } +} |