]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: simplify shifts when the counter fits 6 bits.
authorAlexandru Moșoi <mosoi@google.com>
Thu, 24 Mar 2016 12:40:11 +0000 (13:40 +0100)
committerAlexandru Moșoi <alexandru@mosoi.ro>
Thu, 24 Mar 2016 20:06:34 +0000 (20:06 +0000)
commitafafab3b9736345d150445840dbb603c883bfde4
tree3e93b5c13ab0bc0805865cffa17cabcd61440728
parentd8ee180ab2722e92c568e322fbc8690688f992e3
cmd/compile: simplify shifts when the counter fits 6 bits.

In f the extra & 63 is redundant because SHRQ already
looks at the bottom 6 bits only. This is a trick on AMD64
to get rid of CMPQ/SBBQ/ANDQ if one knows that the shift
counter is small.

func f(x uint64, s uint) uint64 {
        return x >> (s & 63)
}

Change-Id: I4861c902168dabec9a6a14a85750246dde94fc08
Reviewed-on: https://go-review.googlesource.com/21073
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/cmd/compile/internal/ssa/gen/AMD64.rules
src/cmd/compile/internal/ssa/rewriteAMD64.go