Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/compile: SSA runtime performance regression on rotate function #16119

Closed
ALTree opened this issue Jun 19, 2016 · 1 comment
Closed

cmd/compile: SSA runtime performance regression on rotate function #16119

ALTree opened this issue Jun 19, 2016 · 1 comment

Comments

@ALTree
Copy link
Member

ALTree commented Jun 19, 2016

$ gotip version
go version devel +691c5c1 Sun Jun 19 05:18:09 2016 +0000 linux/amd64

Code:

package foo

import "testing"

//go:noinline
func Rotate(x uint64, n uint) uint64 {
    return (x << n) | (x >> uint(64-n))
}

var sink uint64

func BenchmarkRotate(b *testing.B) {
    for n := 0; n < b.N; n++ {
        sink = Rotate(0xff88ff88cc77cc77, 32)
    }
}

(note that the //go:noinline directive is necessary, because tip is able to fold the Rotate call into a load of the result).

go1.6.2 vs tip:

name      old time/op  new time/op  delta
Rotate-4  3.00ns ± 1%  4.36ns ± 0%  +45.09%  (p=0.000 n=10+9)

The problem with the generated code looks similar to the one in #16061 (SSA does two stack spilling and the legacy compiler does not), but this time we're not using instructions that requires values to be in specific registers. I'm not sure whether this can be considered the same as #16061 or not.

@josharian josharian added this to the Go1.8 milestone Jun 19, 2016
@randall77
Copy link
Contributor

This does seem to be the same as #16061. The instruction that requires a value in a specific register is the shift (shift amounts must be in CX).

@golang golang locked and limited conversation to collaborators Sep 15, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants