aboutsummaryrefslogtreecommitdiff
path: root/test/codegen
diff options
context:
space:
mode:
authorLynn Boger <laboger@linux.vnet.ibm.com>2020-03-26 16:01:40 -0400
committerLynn Boger <laboger@linux.vnet.ibm.com>2020-03-27 16:05:42 +0000
commite4a1cf8a5698d7351af0e33d61e4f7078f3ab1ce (patch)
tree4cb51369993067d67eac1850ba373efce872bb96 /test/codegen
parent3840aced142aeeca6ddf54cb90c07b54e4cf814b (diff)
downloadgo-e4a1cf8a5698d7351af0e33d61e4f7078f3ab1ce.tar.gz
go-e4a1cf8a5698d7351af0e33d61e4f7078f3ab1ce.zip
cmd/compile: add rules to eliminate unnecessary signed shifts
This change to the rules removes some unnecessary signed shifts that appear in the math/rand functions. Existing rules did not cover some of the signed cases. A little improvement seen in math/rand due to removing 1 of 2 instructions generated for Int31n, which is inlined quite a bit. Intn1000 46.9ns ± 0% 45.5ns ± 0% -2.99% (p=1.000 n=1+1) Int63n1000 33.5ns ± 0% 32.8ns ± 0% -2.09% (p=1.000 n=1+1) Int31n1000 32.7ns ± 0% 32.6ns ± 0% -0.31% (p=1.000 n=1+1) Float32 32.7ns ± 0% 30.3ns ± 0% -7.34% (p=1.000 n=1+1) Float64 21.7ns ± 0% 20.9ns ± 0% -3.69% (p=1.000 n=1+1) Perm3 205ns ± 0% 202ns ± 0% -1.46% (p=1.000 n=1+1) Perm30 1.71µs ± 0% 1.68µs ± 0% -1.35% (p=1.000 n=1+1) Perm30ViaShuffle 1.65µs ± 0% 1.65µs ± 0% -0.30% (p=1.000 n=1+1) ShuffleOverhead 2.83µs ± 0% 2.83µs ± 0% -0.07% (p=1.000 n=1+1) Read3 18.7ns ± 0% 16.1ns ± 0% -13.90% (p=1.000 n=1+1) Read64 126ns ± 0% 124ns ± 0% -1.59% (p=1.000 n=1+1) Read1000 1.75µs ± 0% 1.63µs ± 0% -7.08% (p=1.000 n=1+1) Change-Id: I11502dfca7d65aafc76749a8d713e9e50c24a858 Reviewed-on: https://go-review.googlesource.com/c/go/+/225917 Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com> Reviewed-by: Cherry Zhang <cherryyz@google.com>
Diffstat (limited to 'test/codegen')
-rw-r--r--test/codegen/shift.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/codegen/shift.go b/test/codegen/shift.go
index f287ca68b7..305c39a1d8 100644
--- a/test/codegen/shift.go
+++ b/test/codegen/shift.go
@@ -125,3 +125,26 @@ func lshGuarded64(v int64, s uint) int64 {
}
panic("shift too large")
}
+
+func checkWidenAfterShift(v int64, u uint64) (int64, uint64) {
+
+ // ppc64le:-".*MOVW"
+ f := int32(v>>32)
+ // ppc64le:".*MOVW"
+ f += int32(v>>31)
+ // ppc64le:-".*MOVH"
+ g := int16(v>>48)
+ // ppc64le:".*MOVH"
+ g += int16(v>>30)
+ // ppc64le:-".*MOVH"
+ g += int16(f>>16)
+ // ppc64le:-".*MOVB"
+ h := int8(v>>56)
+ // ppc64le:".*MOVB"
+ h += int8(v>>28)
+ // ppc64le:-".*MOVB"
+ h += int8(f>>24)
+ // ppc64le:".*MOVB"
+ h += int8(f>>16)
+ return int64(h),uint64(g)
+}