diff options
| author | Matthew Dempsky <mdempsky@google.com> | 2014-12-18 13:50:57 -0800 |
|---|---|---|
| committer | Minux Ma <minux@golang.org> | 2014-12-19 02:50:40 +0000 |
| commit | 481ce36ec43dc699c6be18ec81dfce02ca24601c (patch) | |
| tree | 02b55876815fe8830db39609f0b963278f750bb3 /src/testing/example.go | |
| parent | 7a8e897979c7436f0baa0f7996542dc3c39023f4 (diff) | |
| download | go-481ce36ec43dc699c6be18ec81dfce02ca24601c.tar.xz | |
runtime: simplify cpuprof hash calculation
"x*41" computes the same value as "x*31 + x*7 + x*3" and (when
compiled by gc) requires just one multiply instruction instead of
three.
Alternatively, the expression could be written as "(x<<2+x)<<3 + x" to
use shifts instead of multiplies (which is how GCC optimizes "x*41").
But gc currently emits suboptimal instructions for this expression
anyway (e.g., separate SHL+ADD instructions rather than LEA on
386/amd64). Also, if such an optimization was worthwhile, it would
seem better to implement it as part of gc's strength reduction logic.
Change-Id: I7156b793229d723bbc9a52aa9ed6111291335277
Reviewed-on: https://go-review.googlesource.com/1830
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/testing/example.go')
0 files changed, 0 insertions, 0 deletions
